public inbox for [email protected]
help / color / mirror / Atom feedFrom: BharatDB <[email protected]>
To: [email protected]
To: [email protected]
To: [email protected]
Cc: VASUKI M <[email protected]>
Subject: Re: BUG #19095: Test if function exit() is used fail when linked static
Date: Wed, 12 Nov 2025 11:23:10 +0530
Message-ID: <CAAh00ETwx8_AEM0wgoi-v875uC-FLuGGOMTaP9fCNdVw4Zq=Vg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
>
>
> Hello Hackers,
>
> While reproducing a static linking issue between libpq and libcrypto.a,
> I observed that the Makefile's symbol check incorrectly reports missing
> exit() symbols because 'grep exit' also matches 'atexit' and
> 'OPENSSL_atexit', etc.
>
> As discussed in the thread by Michael Paquier
> (https://www.postgresql.org/message-id/aQA1obboZFjqjaBI%40paquier.xyz),
> it seems a related fix was committed earlier. However, I was able to
> reproduce this issue again using PostgreSQL 18 (latest release).
>
> Steps to reproduce:
> nm -A -u ./src/interfaces/libpq/libpq.a
> /usr/lib/x86_64-linux-gnu/libcrypto.a 2>/dev/null | grep -v __cxa_atexit |
> grep exit
>
> Output:
> /usr/lib/x86_64-linux-gnu/libcrypto.a:libcrypto-lib-init.o:
> U atexit
> /usr/lib/x86_64-linux-gnu/libcrypto.a:libdefault-lib-rand_unix.o:
> U OPENSSL_atexit
>
> This falsely triggers an undefined exit() error.
> [1]Changing the grep pattern to match the exact symbol ('grep -x exit')
> prevents
> such false positives.
[2]Alternatively, excluding pthread_exit() (similar to
> __cxa_atexit) would also avoid the issue.
>
> But [1] will handle all the false positives instead of just pthread_exit
.LGTM
Expected (after fix):
> no output — no false positives.
>
> Patch attached.I would love to hear any suggestions from the committers.
>
Thanks in advance
>
> Best regards,
> Vasuki M
>
BharatDB,
> CDAC Chennai.
>
Attachments:
[text/x-patch] 0001-Fix-prevent-false-exit-match-in-libpq-static-link-ch.patch (1.2K, 3-0001-Fix-prevent-false-exit-match-in-libpq-static-link-ch.patch)
download | inline diff:
From 6ba784e27f6d2a7023828263f988b7a2716fe614 Mon Sep 17 00:00:00 2001
From: BharatDBPG <[email protected]>
Date: Tue, 11 Nov 2025 17:36:29 +0530
Subject: [PATCH] Fix: prevent false exit() match in libpq static link check
The previous Makefile check used 'grep exit', which also matched
symbols like 'atexit' and 'OPENSSL_atexit' from libcrypto.a.
This caused false positive link failures when statically linking
libpq with OpenSSL.
Use 'grep -x exit' to match only the exact symbol name.
Signed-off-by: BharatDBPG <[email protected]>
---
src/interfaces/libpq/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index da66500..8cff30b 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -144,7 +144,7 @@ $(stlib): $(OBJS_STATIC)
libpq-refs-stamp: $(shlib)
ifneq ($(enable_coverage), yes)
ifeq (,$(filter solaris,$(PORTNAME)))
- @if nm -A -u $< 2>/dev/null | grep -v -e __cxa_atexit -e __tsan_func_exit | grep exit; then \
+ @if nm -A -u $< 2>/dev/null | grep -v -e __cxa_atexit -e __tsan_func_exit | grep -x exit; then \
echo 'libpq must not be calling any function which invokes exit'; exit 1; \
fi
endif
--
2.43.0
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: BUG #19095: Test if function exit() is used fail when linked static
In-Reply-To: <CAAh00ETwx8_AEM0wgoi-v875uC-FLuGGOMTaP9fCNdVw4Zq=Vg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox