Re: BUG #19095: Test if function exit() is used fail when linked static

From: VASUKI M <vasukim1992002(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, BharatDB <bharatdbpg(at)gmail(dot)com>, torsten(dot)rupp(at)gmx(dot)net, pgsql-bugs(at)lists(dot)postgresql(dot)org, byavuz81(at)gmail(dot)com
Subject: Re: BUG #19095: Test if function exit() is used fail when linked static
Date: 2025-12-03 11:59:33
Message-ID: CACTYHzjjssid_jtZiLh8BTYHAvnxbSLXceyGtxM3NB6Kfv510g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi Hackers,

This is a refreshed version of the patch to unify the exit() reference check
performed during libpq builds. Earlier versions had duplicated logic between
the Makefile and Meson builds, while platform-specific details were also
split
between comments and build rules.

Following feedback from Michael, Daniel, Tom, and Nazir, v4 includes the
following changes:
Changes in v4

-

Added top-level AC_PATH_PROG(NM, nm) in configure.ac, and propagated
it via NM, so both build systems use the same nm path.
-

Updated Makefile and Meson rules to invoke the new Perl helper using
-

- -nm=$(NM) / - -nm=(at)NM@
-

Centralized all platform-specific behavior in the Perl script:
-

Skip on Solaris and Windows
-

Handle ThreadSanitizer (__tsan_func_exit)
-

Handle OpenBSD’s __cxa_atexit
-

Whitelist pthread_exit()
-

Gracefully skip if nm is not available
-

Removed redundant checks from meson.build and Makefile and replaced them
with
a short reference to the script.
-

Added missing cleanup (closing filehandle), and improved comments.
-

Ensured consistent behavior across autoconf and Meson builds.

Testing:

Both autoconf and Meson builds were tested with:

-

Valid nm present
-

Missing nm
-

Solaris/Windows-skip behavior
-

Injected exit() symbol to confirm failure mode works correctly

The behavior is now uniform across build systems.

Patch is attached.

Thanks for the reviews so far, and I welcome further comments.

Regards,
Vasuki

>
> On Wed, 26 Nov 2025 at 09:13, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
>> On Tue, Nov 25, 2025 at 11:51:55AM +0100, Daniel Gustafsson wrote:
>> > +if find_program('nm', required: false, native: true).found() and not
>> get_option('b_coverage')
>> > Sorry for being late to the party, but I wonder why we aren't adding
>> this check
>> > to the toplevel meson.build and configure.ac (via config/programs.m4)
>> like how
>> > we check for all others tools used by the build? Such checks should of
>> course
>> > not fail the configuration, merely record the presence or absence of
>> the tool.
>> > The path can then be exported to
>> src/interfaces/libpq/{Makefile|meson.build} to
>> > use.
>>
>> +1 for this find_program() call grouped at the top of meson.build,
>> grouped with the others.
>>
> Fixed in the v4 please review it.

> --
>> Michael
>>
>

Attachment Content-Type Size
v4-0001-libpq-centralize-exit-check-logic-and-unify-Makef.patch text/x-patch 8.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-03 12:04:11 Re: POC: make mxidoff 64 bits
Previous Message cca5507 2025-12-03 11:48:10 Support loser tree for k-way merge

Browse pgsql-bugs by date

  From Date Subject
Previous Message Dean Rasheed 2025-12-03 11:38:50 Re: BUG #19340: Wrong result from CORR() function