Re: [BUG] PostgreSQL crashes with ThreadSanitizer during early initialization

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: Emmanuel Sibi <emmanuelsibi(dot)mec(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: [BUG] PostgreSQL crashes with ThreadSanitizer during early initialization
Date: 2025-11-05 01:19:35
Message-ID: 707073.1762305575@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> writes:
> On Tue, Nov 4, 2025 at 2:39 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Another problem is that it only defends against a limited set of
>> sanitizers, though presumably every single one is broken in the same
>> way (compare [1]).

> How about __attribute__((disable_sanitizer_instrumentation)) ? LLVM's
> own tests make some use of this [1].

Hah, thanks for the research! For me, this stops the failure
(on RHEL9 with clang version 19.1.7):

diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index bdcb5e4f261..1bd63ec9184 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -500,6 +500,10 @@ check_root(const char *progname)
* seem necessary to only compile it conditionally.
*/
const char *__ubsan_default_options(void);
+
+#if __has_attribute(disable_sanitizer_instrumentation)
+__attribute__((disable_sanitizer_instrumentation))
+#endif
const char *
__ubsan_default_options(void)
{

Assuming that works for Emmanuel, we could wrap it in a
pg_disable_sanitizer_instrumentation macro, or just use it
as-is. I don't have a strong preference --- any thoughts?

(It could do with a comment, either way.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Naga Appani 2025-11-05 01:13:09 Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring