The following commit broke glibc on alpha-linux-gnu, in this case Debian unstable running on Alpha: commit 6c57d320484988e87e446e2e60ce42816bf51d53 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Feb 1 11:00:38 2021 -0800 sysconf: Add _SC_MINSIGSTKSZ/_SC_SIGSTKSZ [BZ #20305] Add _SC_MINSIGSTKSZ for the minimum signal stack size derived from AT_MINSIGSTKSZ, which is the minimum number of bytes of free stack space required in order to gurantee successful, non-nested handling of a single signal whose handler is an empty function, and _SC_SIGSTKSZ which is the suggested minimum number of bytes of stack space required for a signal stack. Without the patch applied, running bash in a qemu-user-static chroot from the build directory of a cross-compiled build works fine: (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ LD_LIBRARY_PATH=/home/glaubitz/glibc-git/build /bin/bash (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ exit With the patch applied, the above command results in a segmentation fault: (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ LD_LIBRARY_PATH=/home/glaubitz/glibc-git/build /bin/bash Segmentation fault (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ The issue also becomes apparent when comparing the testsuite failures for glibc-2.33 and glibc-2.34 in Debian unstable: > https://buildd.debian.org/status/fetch.php?pkg=glibc&arch=alpha&ver=2.33-8&stamp=1657736413&raw=0 > https://buildd.debian.org/status/fetch.php?pkg=glibc&arch=alpha&ver=2.34-1&stamp=1659947712&raw=0
What are values of SIGSTKSZ and MINSIGSTKSZ before and after the commit?
(In reply to H.J. Lu from comment #1) > What are values of SIGSTKSZ and MINSIGSTKSZ before and after the commit? I'm not sure how to read out those values as I tried it with small test program which crashes after the commit. Without commit, I get: (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ /bz20305 The value of SIGSTKSZ is 16384. The value of MINSIGSTKSZ is 4096. (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ I used the following test program: #include <stdio.h> #include <signal.h> int main() { printf("The value of SIGSTKSZ is %d.\n", SIGSTKSZ); printf("The value of MINSIGSTKSZ is %d.\n", MINSIGSTKSZ); return 0; } Do you have any other suggestion for dumping the values?
(In reply to John Paul Adrian Glaubitz from comment #2) > (In reply to H.J. Lu from comment #1) > > What are values of SIGSTKSZ and MINSIGSTKSZ before and after the commit? > > I'm not sure how to read out those values as I tried it with small test > program which crashes after the commit. > > Without commit, I get: > > (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ /bz20305 > The value of SIGSTKSZ is 16384. > The value of MINSIGSTKSZ is 4096. > (sid-alpha-sbuild)glaubitz@z6:~/glibc-git/build$ > > I used the following test program: > > #include <stdio.h> > #include <signal.h> > > int main() { > > printf("The value of SIGSTKSZ is %d.\n", SIGSTKSZ); > printf("The value of MINSIGSTKSZ is %d.\n", MINSIGSTKSZ); > > return 0; > } > > Do you have any other suggestion for dumping the values? Why does this program crash with the commit?
(In reply to H.J. Lu from comment #3) > Why does this program crash with the commit? That's what I am trying to find out. I suspect that the values of MINSIGSTKSZ and SIGSTKSZ are not the cause of the problem.
This is the minimum change directly on top the commit that fixes the problem for me: diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c index bd5066fe3b..bc45a6e9d3 100644 --- a/elf/dl-sysdep.c +++ b/elf/dl-sysdep.c @@ -115,10 +115,10 @@ _dl_sysdep_start (void **start_argptr, user_entry = (ElfW(Addr)) ENTRY_POINT; GLRO(dl_platform) = NULL; /* Default to nothing known about the platform. */ - /* NB: Default to a constant CONSTANT_MINSIGSTKSZ. */ - _Static_assert (__builtin_constant_p (CONSTANT_MINSIGSTKSZ), - "CONSTANT_MINSIGSTKSZ is constant"); - GLRO(dl_minsigstacksize) = CONSTANT_MINSIGSTKSZ; + /* /\* NB: Default to a constant CONSTANT_MINSIGSTKSZ. *\/ */ + /* _Static_assert (__builtin_constant_p (CONSTANT_MINSIGSTKSZ), */ + /* "CONSTANT_MINSIGSTKSZ is constant"); */ + /* GLRO(dl_minsigstacksize) = CONSTANT_MINSIGSTKSZ; */ for (av = GLRO(dl_auxv); av->a_type != AT_NULL; set_seen (av++)) switch (av->a_type) @@ -184,9 +184,9 @@ _dl_sysdep_start (void **start_argptr, case AT_RANDOM: _dl_random = (void *) av->a_un.a_val; break; - case AT_MINSIGSTKSZ: - GLRO(dl_minsigstacksize) = av->a_un.a_val; - break; + /* case AT_MINSIGSTKSZ: */ + /* GLRO(dl_minsigstacksize) = av->a_un.a_val; */ + /* break; */ DL_PLATFORM_AUXV } diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 9720a4e446..9ead714718 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -536,8 +536,8 @@ struct rtld_global_ro /* Cached value of `getpagesize ()'. */ EXTERN size_t _dl_pagesize; - /* Cached value of `sysconf (_SC_MINSIGSTKSZ)'. */ - EXTERN size_t _dl_minsigstacksize; + /* /\* Cached value of `sysconf (_SC_MINSIGSTKSZ)'. *\/ */ + /* EXTERN size_t _dl_minsigstacksize; */ /* Do we read from ld.so.cache? */ EXTERN int _dl_inhibit_cache; diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index 366fcef01e..5a5c89f80e 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -77,12 +77,12 @@ __sysconf (int name) } break; - case _SC_MINSIGSTKSZ: - assert (GLRO(dl_minsigstacksize) != 0); - return GLRO(dl_minsigstacksize); + /* case _SC_MINSIGSTKSZ: */ + /* assert (GLRO(dl_minsigstacksize) != 0); */ + /* return GLRO(dl_minsigstacksize); */ - case _SC_SIGSTKSZ: - return sysconf_sigstksz (); + /* case _SC_SIGSTKSZ: */ + /* return sysconf_sigstksz (); */ default: break; So, my suspicion is that adding the variable _dl_minsigstacksize to struct rtld_global_ro {} breaks the ABI on Alpha.
(In reply to John Paul Adrian Glaubitz from comment #5) > So, my suspicion is that adding the variable _dl_minsigstacksize to struct > rtld_global_ro {} breaks the ABI on Alpha. rtld_global_ro is private to glibc. Are there any hardcoded rtld_global_ro related values on Alpha?
It seems that this issue has been fixed in version 2.36 but there is another issue which so far I have failed to bisect: (sid-alpha-sbuild)glaubitz@nofan:~/glibc-git/build$ LD_LIBRARY_PATH=/home/glaubitz/glibc-git/build /bin/bash Floating point exception (sid-alpha-sbuild)glaubitz@nofan:~/glibc-git/build$
After discussing this issue with Adhemveral, it turns out that my testing method was incorrect and the segfault was a result of mixing ld.so and libc.so from different glibc builds which, of course, doesn't work. Closing this issue although the original problem may still exist. It affects statically linked programs only, however.