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-23 21:40:57
Message-ID: 6dea1cfa-1efd-41cb-8d1e-ad35d4304aa3@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/23/2026 2:16 PM, Álvaro Herrera wrote:
> Hello, thanks for following up.
>
> However, I was going over the commit message one final time after your
> reply, and I noticed that SymInitialize()'s documentation says quite
> explicitly:
>
> "Do not use the handle returned by GetCurrentProcess"
> https://learn.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-syminitialize
>
> which is exactly what we do with this patch.
>
> I think we should DuplicateHandle() on the GetCurrentProcess() handle
> (which then obviously needs CloseHandle afterwards). Would you agree?
>
> Here's the whole thing again with edited commit message and some trivial
> stylistic changes.
>
>
> I was amused to discover that Solaris, macOS and FreeBSD all copied the
> backtrace() interface from glibc, and the only platform in the buildfarm
> other than Windows that seems to lack support for backtraces is Alpine
> Linux.
>
> Regards
>
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.

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

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-02-23 22:07:47 Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)
Previous Message Nathan Bossart 2026-02-23 21:33:46 Re: convert SpinLock* macros to static inline functions