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-01T01:23:28Z
Lists: pgsql-hackers
On Wed, Jun 30, 2021 at 12:06:47PM -0400, Tom Lane wrote:
> I wrote:
> > OK, thanks, will push a fix momentarily.
> 
> Did so, and look what popped up on wrasse [1]:
> 
> ! nm -A -g -u libpq.so.5.15 2>/dev/null | grep -v __cxa_atexit | grep exit
> libpq.so.5.15: [765]	|              232544|                 248|FUNC |GLOB |3    |14     |PQexitPipelineMode
> 
> This makes no sense, because (a) wrasse was happy with the previous
> version, and (b) surely the "-u" switch should prevent nm from
> printing PQexitPipelineMode.  Noah, did you change anything about
> wrasse's configuration today?

No, and wrasse still succeeds at "git checkout e45b0df^".  Solaris
/usr/bin/grep doesn't support "-e":

[nm@gcc-solaris11 5:0 2021-06-30T22:23:29 postgresql 0]$ echo exit | grep -e exit
grep: illegal option -- e
Usage: grep [-c|-l|-q] -bhinsvw pattern file . . .
[nm@gcc-solaris11 5:0 2021-06-30T22:23:43 postgresql 2]$ echo exit | grep exit
exit
[nm@gcc-solaris11 5:0 2021-06-30T22:24:16 postgresql 0]$ echo exit | /usr/xpg4/bin/grep -e exit
exit

That concealed things in the previous version.  You can see those "illegal
option" messages in the last passing run:
https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=wrasse&dt=2021-06-30%2008%3A57%3A27&stg=make



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