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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add a build-time check that libpq doesn't call exit() or abort()
Date: 2021-06-29 15:46:30
Message-ID: E1lyFwU-00007U-Bd@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Directly exiting or aborting seems like poor form for a general-purpose
library. Now that libpq liberally uses bits out of src/common/,
it's very easy to accidentally include code that would do something
unwanted like calling exit(1) after OOM --- see for example 8ec00dc5c.
Hence, add a simple cross-check that no such calls have made it into
libpq.so.

The cross-check depends on nm(1) being available and being able to
work on a shared library, which probably isn't true everywhere.
But we can just make the test silently do nothing if nm fails.
As long as the check is effective on common platforms, that should
be good enough. (By the same logic, I've not worried about providing
an equivalent test in MSVC builds.)

Discussion: https://postgr.es/m/3128896.1624742969@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dc227eb82ea8bf6919cd81a182a084589ddce7f3

Modified Files
--------------
src/interfaces/libpq/Makefile | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-06-29 18:34:49 pgsql: Fix bogus logic for reporting which hash partition conflicts.
Previous Message Tom Lane 2021-06-29 15:31:24 pgsql: Remove libpq's use of abort(3) to handle mutex failure cases.