agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
From: Bryan Green <dbryan.green@gmail.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Euler Taveira <euler@eulerto.com>
Cc: Jakub Wartak <jakub.wartak@enterprisedb.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)
Date: Mon, 23 Feb 2026 21:36:31 -0600
Message-ID: <043bf2c3-d39a-4592-be83-bf68eb1befcf@gmail.com> (raw)
In-Reply-To: <202602232201.2d5ez5tbrkg2@alvherre.pgsql>
References: <202602232201.2d5ez5tbrkg2@alvherre.pgsql>

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.
> 
backtrace_cleanup() only cleans up on process exit-- so, it is almost a
style choice.  If we are going to close the handle in cleanup we should
probably stay consistent and reset backtrace_process to null as well.

If SymInitialize() fails...I can not imagine it ever succeeding after
that.  It is an expensive call...a process generating errors shouldn't
be burning time retrying a failing system call on every error.

I agree with not retrying.  I'll put together another patch with those
changes.

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





view thread (36+ messages)  latest in thread

Message-ID: <043bf2c3-d39a-4592-be83-bf68eb1befcf@gmail.com>
Permalink:  ../043bf2c3-d39a-4592-be83-bf68eb1befcf@gmail.com/
Also on:    postgresql.org/message-id/043bf2c3-d39a-4592-be83-bf68eb1befcf@gmail.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: dbryan.green@gmail.com, alvherre@kurilemu.de, euler@eulerto.com, jakub.wartak@enterprisedb.com, michael@paquier.xyz
  Subject: Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)
  In-Reply-To: <043bf2c3-d39a-4592-be83-bf68eb1befcf@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox