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>, info@cspug.cz
Date: 2021-06-29T20:39:28Z
Lists: pgsql-hackers
I wrote:
> 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

After a few more hours, all of our OpenBSD animals have reported
that, on several different OpenBSD releases and with both gcc
and clang compilers.  So at least it's a longstanding platform
behavior.

More troublingly, fossa reports this:

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

Where is that coming from?  hippopotamus and jay, which seem to
be different compilers on the same physical machine, aren't showing
it.  That'd lead to the conclusion that icc is injecting abort()
calls of its own accord, which seems quite nasty.  Lacking an icc
license, I can't poke into that more directly here.

Perhaps we could wrap the test for abort() in something like
'if "$CC" != icc then ...', but ugh.

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