Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)

From: Bryan Green <dbryan(dot)green(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: Euler Taveira <euler(at)eulerto(dot)com>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)
Date: 2026-02-24 04:31:55
Message-ID: 0f76b00a-8d8d-4c6f-ba41-bf6ec5fb08e1@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/23/2026 4:07 PM, Álvaro Herrera wrote:
> On 2026-Feb-23, Bryan Green wrote:
>
>> I have implemented DuplicateHandle and closed the handle in the
>> appropriate places. I also reset backtrace_process to NULL if
>> SymInitialize() fails. Patch is attached.
>
> Hmm, should then backtrace_cleanup() cope with the case where it's NULL?
>
> Also, I wonder what happens if one "backtraceable" error occurs, and we
> fail to SymInitialize(), then another backtraceable error occurs.
> Should we do the DuplicateHandle()+SymInitialize() dance again, or
> should we just give up? The current implementation does the former, I
> think; but the latter is also easily achievable by setting
> backtrace_symbols_initialized to true and leaving backtrace_process as
> NULL; then this case can be detected specifically in set_backtrace() and
> treated as a case where we just return NULL before attempting anything
> else.
>
I have removed all but the SymCleanup form the backtrace_cleanup since
it happens at process exit. I have implemented not retrying as you
described above.

Let me know if this was what you were thinking.

Patch attached.

--
Bryan Green
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
v10-0001-Add-backtrace-support-for-Windows-using-DbgHelp-A.patch text/plain 9.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2026-02-24 04:38:32 Re: Row pattern recognition
Previous Message Chao Li 2026-02-24 04:25:19 Re: Modernize error message for malformed B-Tree tuple posting