Re: BUG #19095: Test if function exit() is used fail when linked static

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Daniel Gustafsson <daniel@yesql.se>, Michael Paquier <michael@paquier.xyz>, BharatDB <bharatdbpg@gmail.com>, torsten.rupp@gmx.net, pgsql-bugs@lists.postgresql.org, VASUKI M <vasukim1992002@gmail.com>
Date: 2025-11-14T14:40:46Z
Lists: pgsql-bugs, pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. libpq: Authorize pthread_exit() in libpq_check

  2. Fix meson warning due to missing declaration of NM

  3. libpq: Refactor logic checking for exit() in shared library builds

Andres Freund <andres@anarazel.de> writes:
> But more generally: If we allow pthread_exit(), what's the point of this test?
> That's one of the functions we better avoid calling, no?

ATM it's not something we'd be tempted to call, but I take your point.

> ISTM that if we do want to continue having this test, the issue is that we're
> testing the shared library - which will have already linked against static
> libraries like the sanitizer ones or in this case libcrypto. What we ought to
> do is to test the .o files constituting libpq.so, rather than the already
> linked .so. That way we will find our own calls to exit etc, but not ones in
> static libraries.

My recollection is that that doesn't help as much as you'd think.
__tsan_func_exit, for one, can get injected into our own .o files
if we build with appropriate sanitizers enabled.

			regards, tom lane