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

From: Emmanuel Sibi <emmanuelsibi(dot)mec(at)gmail(dot)com>
To: Quan Zongliang <quanzongliang(at)yeah(dot)net>
Cc: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [BUG] PostgreSQL crashes with ThreadSanitizer during early initialization
Date: 2025-09-15 15:19:01
Message-ID: CAJhJm+iE0mEAuQ314_iVHG4qpHj8M1u7z4MV0DzbqnHUOVAQOg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Quan, Thanks for testing the patch! I'm glad it resolves the startup crash.
> I tested this patch. postgres -V no longer crashes.

Regarding the shutdown issue - I tested extensively with
ThreadSanitizer enabled using both build configurations I mentioned
earlier, and all shutdown modes work correctly in my environment:
> There is a minor issue. I'm not sure if it's caused by this patch.
> The database can only be shut down using the immediate mode.

Fast shutdown:
2025-09-15 20:20:07.454 IST [28229] LOG: received fast shutdown request
[...]
2025-09-15 20:20:07.574 IST [28229] LOG: database system is shut down
Smart shutdown:
2025-09-15 20:28:14.271 IST [31263] LOG: received smart shutdown request
[...]
2025-09-15 20:28:14.399 IST [31263] LOG: database system is shut down

All modes complete within seconds with the final "database system is
shut down" message, unlike the hang you're experiencing.
The patch only moves __ubsan_default_options() to a separate
compilation unit to avoid TSan initialization issues during startup.
It doesn't modify any shutdown logic or signal handling code.
My Environment: Ubuntu 24.04.1, clang 18, PostgreSQL 17.2.

Best regards,
Emmanuel

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Maxim Orlov 2025-09-15 15:42:00 Re: POC: make mxidoff 64 bits
Previous Message Peter Geoghegan 2025-09-15 15:12:16 Re: index prefetching