From: Michael Paquier <michael@paquier.xyz>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
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 17:13:44 +0900
Message-ID: <ZcXeuOl9qy7YA9RH@paquier.xyz> (raw)
In-Reply-To: <ZcRJnhN8jWrPxwxM@paquier.xyz>
References: <CALDaNm1K8wAQ-zTmbyVuHXJszgKfUQh6tGrdfDuWm2Fe=jfobQ@mail.gmail.com>
<202401261041.tnf6wsga2zvm@alvherre.pgsql>
<CALj2ACUD4-TaRWRHpS3mRtr=6oiD8P57VF-oAVE2-RxrMA7F5g@mail.gmail.com>
<ZcIO_yD1LNpjGbsh@paquier.xyz>
<CALj2ACVJwDcw8DyCdYMn4R5oa0gCtfq3w5QKD7Tx6NqyU+AuFQ@mail.gmail.com>
<ZcNNAA0DsLA3azNM@paquier.xyz>
<CALj2ACW3JuxHYn2bmgrdcR_D-QUwNk2Z_fxEqQ+=e6oNei8rkg@mail.gmail.com>
<CALj2ACWj0omM=o0p6--+AKrE0U=tWt82ytHWfLzrRQX=QEmWew@mail.gmail.com>
<ZcRJnhN8jWrPxwxM@paquier.xyz>
On Thu, Feb 08, 2024 at 12:25:18PM +0900, Michael Paquier wrote:
> In HandleLogBacktraceInterrupt(), we don't use backtrace_symbols() and
> rely on backtrace_symbols_fd() to avoid doing malloc() in the signal
> handler as mentioned in [1] back in 2022. Perhaps the part about the
> fact that we don't use backtrace_symbols() should be mentioned
> explicitely in a comment rather than silently implied? That's
> a very important point.
This has been itching me, so I have spent more time reading about
that, and while browsing signal(7) and signal-safety(7), I've first
noticed that this is not safe in the patch:
+ write_stderr("logging current backtrace of process with PID %d:\n",
+ MyProcPid);
Note that there's a write_stderr_signal_safe().
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.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (832B, ../ZcXeuOl9qy7YA9RH@paquier.xyz/2-signature.asc)
download
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: michael@paquier.xyz, bharath.rupireddyforpostgres@gmail.com, alvherre@alvh.no-ip.org, vignesh21@gmail.com, torikoshia@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Printing backtrace of postgres processes
In-Reply-To: <ZcXeuOl9qy7YA9RH@paquier.xyz>
* 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