From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: vignesh C <vignesh21@gmail.com>
Cc: torikoshia <torikoshia@oss.nttdata.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Printing backtrace of postgres processes
Date: Fri, 9 Feb 2024 09:48:36 +0100
Message-ID: <202402090848.j6evnpunbehe@alvherre.pgsql> (raw)
In-Reply-To: <ZcXeuOl9qy7YA9RH@paquier.xyz>
On 2024-Feb-09, Michael Paquier wrote:
> Anyway, I've been digging around the signal-safety of backtrace(3)
> (even looking a bit at some GCC code, brrr), and I am under the
> impression that backtrace() is just by nature not safe and also
> dangerous in signal handlers. One example of issue I've found:
> https://github.com/gperftools/gperftools/issues/838
>
> This looks like enough ground to me to reject the patch.
Hmm, but the backtrace() manpage says
• backtrace() and backtrace_symbols_fd() don't call malloc() explic‐
itly, but they are part of libgcc, which gets loaded dynamically
when first used. Dynamic loading usually triggers a call to mal‐
loc(3). If you need certain calls to these two functions to not
allocate memory (in signal handlers, for example), you need to make
sure libgcc is loaded beforehand.
and the patch ensures that libgcc is loaded by calling a dummy
backtrace() at the start of the process.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"All rings of power are equal,
But some rings of power are more equal than others."
(George Orwell's The Lord of the Rings)
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: alvherre@alvh.no-ip.org, michael@paquier.xyz, bharath.rupireddyforpostgres@gmail.com, vignesh21@gmail.com, torikoshia@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Printing backtrace of postgres processes
In-Reply-To: <202402090848.j6evnpunbehe@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox