diff mbox series

m4: Fix ptest hang with glibc 2.44

Message ID 20260729162347.4037154-1-khem.raj@oss.qualcomm.com
State New
Headers show
Series m4: Fix ptest hang with glibc 2.44 | expand

Commit Message

Khem Raj July 29, 2026, 4:23 p.m. UTC
glibc 2.44 declares the POSIX 2024 name posix_spawn_file_actions_addchdir in
<spawn.h> as an asm level alias of the long standing
posix_spawn_file_actions_addchdir_np [1]:

  extern int __REDIRECT_NTH (posix_spawn_file_actions_addchdir,
                             (posix_spawn_file_actions_t *, const char *),
                             posix_spawn_file_actions_addchdir_np);

There is no symbol exported under the standard name though. gnulib probes for the
function with AC_CHECK_FUNCS, which does not include <spawn.h>, so it does not
see the alias and concludes the function is missing. gnulib then compiles its
own lib/spawn_faction_addchdir.c, but the header attaches the asm name
posix_spawn_file_actions_addchdir_np to that identifier, as a result the
*definition* is emitted under the _np name while its body does

  return posix_spawn_file_actions_addchdir_np (file_actions, path);

i.e. it calls itself (INFINITE LOOP). It overrides the real
glibc symbol for the whole program:

  0000000000000000 <posix_spawn_file_actions_addchdir_np>:
     0:	eb fe                	jmp    0 <posix_spawn_file_actions_addchdir_np>

tests/test-execute.sh case 21 therefore spins there forever. Because gnulib's
execute() blocks the fatal signals before spawning, the hung process also
ignores SIGTERM and ptest-runner has to SIGKILL it.

m4 cannot be autoreconf'd (m4-native sets INHIBIT_AUTOTOOLS_DEPS and overrides
do_configure, as autoreconf needs m4), so fix the probe result directly:
reached through <spawn.h> the function really is available. gnulib then takes
its REPLACE_ code path, which names the definition rpl_* so that it no longer
collides with the glibc symbol it forwards to:

  0000000000000000 <rpl_posix_spawn_file_actions_addchdir>:
     0:	e9 00 00 00 00       	jmp    5 <rpl_posix_spawn_file_actions_addchdir+0x5>
  			1: R_X86_64_PLT32	posix_spawn_file_actions_addchdir_np-0x4

The underlying gnulib probe is still wrong upstream and it is reported [2] and also
discussed in glibc bugzilla [3]

[1] https://sourceware.org/cgit/glibc/commit/?id=7594b4e5a75d41e891782aa7e3fb51924f6840cb
[2] https://lists.gnu.org/archive/html/bug-gnulib/2026-07/msg00164.html
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=34437

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 meta/recipes-devtools/m4/m4-1.4.21.inc | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/m4/m4-1.4.21.inc b/meta/recipes-devtools/m4/m4-1.4.21.inc
index 1af9b9a783..3be6a521a8 100644
--- a/meta/recipes-devtools/m4/m4-1.4.21.inc
+++ b/meta/recipes-devtools/m4/m4-1.4.21.inc
@@ -23,6 +23,11 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464\
 
 EXTRA_OECONF += "--without-libsigsegv-prefix"
 
+# see https://lists.gnu.org/archive/html/bug-gnulib/2026-07/msg00165.html
+# Drop it when upgrading to next release where above fix is accepted
+CACHED_CONFIGUREVARS:append:libc-glibc = " ac_cv_func_posix_spawn_file_actions_addchdir=yes"
+CACHED_CONFIGUREVARS:append:class-native = " ac_cv_func_posix_spawn_file_actions_addchdir=yes"
+
 EXTRA_OEMAKE += "'infodir=${infodir}'"
 
 do_compile_ptest() {