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

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

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Jacob Champion <pchampion@vmware.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Daniel Gustafsson <daniel@yesql.se>
Date: 2021-06-29T17:15:30Z
Lists: pgsql-hackers
I wrote:
>> This relies on "nm" being able to work on shlibs, which it's not
>> required to by POSIX.  However, it seems to behave as desired even
>> on my oldest dinosaurs.  In any case, if "nm" doesn't work then
>> we'll just not detect such problems on that platform, which should
>> be OK as long as the test does work on common platforms.

So I pushed that, and not very surprisingly, it's run into some
portability problems.  gombessa (recent OpenBSD) reports

! nm -A -g -u libpq.so.5.15 2>/dev/null | grep -v '_eprintf\\.o:' | grep -e abort -e exit
libpq.so.5.15:__cxa_atexit

So far as I can find, __cxa_atexit is a C++ support routine, so
I wondered what the heck libpq.so is doing calling it.  I managed
to reproduce the failure here using an OpenBSD installation I had
at hand, and confirmed that __cxa_atexit is *not* referenced by any
of the .o files in src/port, src/common, or src/interfaces/libpq.
So apparently it's being injected at some fairly low level of the
shlib support on that platform.

Probably the thing to do is adjust the grep filter to exclude
__cxa_atexit, but I want to wait awhile and see whether any
other buildfarm animals report this.  morepork at least will
be pretty interesting, since it's a slightly older OpenBSD
vintage.

			regards, tom lane



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().