Re: Preventing abort() and exit() calls in libpq

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Michael Paquier <michael@paquier.xyz>, Jacob Champion <pchampion@vmware.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Daniel Gustafsson <daniel@yesql.se>, info@cspug.cz
Date: 2021-07-03T00:16:39Z
Lists: pgsql-hackers
On Fri, Jul 02, 2021 at 11:20:17AM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> > Now it's hoverfly:
> > ! nm -A -u libpq.so.5 2>/dev/null | grep -v __cxa_atexit | grep exit
> > libpq.so.5: atexit               U           -
> > libpq.so.5: pthread_exit         U           -
> 
> Ugh.  What in the world is producing those references?

Those come from a statically-linked libldap_r:

$ nm -A -u /home/nm/sw/nopath/openldap-64/lib/libldap_r.a|grep exit
/home/nm/sw/nopath/openldap-64/lib/libldap_r.a[tpool.o]: .ldap_pvt_thread_exit U           -
/home/nm/sw/nopath/openldap-64/lib/libldap_r.a[thr_posix.o]: .pthread_exit        U           -
/home/nm/sw/nopath/openldap-64/lib/libldap_r.a[init.o]: .atexit              U           -



Commits

  1. Further restrict the scope of no-exit()-in-libpq test.

  2. Improve build-time check that libpq doesn't call exit().

  3. Fix portability fallout from commit dc227eb82.

  4. Add a build-time check that libpq doesn't call exit() or abort().