[Bug libc/34297] New: s390x: static binaries crash at startup for some configurations

"adhemerval.zanella at linaro dot org via Glibc-bugs" <[email protected]> Wed, 17 Jun 2026 13:30:18 +0000
Newsgroups gmane.comp.lib.glibc.bugs
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34297

            Bug ID: 34297
           Summary: s390x: static binaries crash at startup for some
                    configurations
           Product: glibc
           Version: 2.29
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: adhemerval.zanella at linaro dot org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Statically linked programs segfault during __libc_start_main, before reaching
the program's main(). It does not happen for all s390x configuration, on gcc
16:

s390x-linux-gnu-arch5   OK
s390x-linux-gnu-z900    OK
s390x-linux-gnu-z196    FAIL
s390x-linux-gnu-z10     FAIL
s390x-linux-gnu-z13     FAIL

__libc_start_main() calls ARCH_SETUP_TLS(), which installs the thread pointer
into the s390 access registers a0/a1, and then stores the stack/pointer guards
into the TCB via THREAD_SET_STACK_GUARD / THREAD_SET_POINTER_GUARD.

Those macros read the thread pointer with__builtin_thread_pointer(), an the
compiler treats the access-register read as invariant. Depending of the
register pressure and the targetting ISA, the reconstructed thread pointer
might have its  bits zeroed.

The pre-existing barrier inside THREAD_SET_STACK_GUARD (__asm__ __volatile__
("" : : : "a0", "a1")) forces a re-read of a0/a1 but does not anchor it after
the opaque __libc_setup_tls call, so it does not prevent the hoist.

-- 
You are receiving this mail because:
You are on the CC list for the bug.