https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112551
Bug ID: 112551
Summary: Incompatibility of libstdc++ liked statically and
-Bsymbolic-functions
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
Created attachment 56595
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56595&action=edit
reproducer
Hey folks,
While debugging a firefox issue, we found an interesting bug where a program
linked statically against libstdc++ and dynamically against a library that's
itself statically linked against libstdc++, both with -Bsymbolic-functions, is
segfaulting at startup (during Elf con structor init)
The attached tarball provides a minimal reproducer.
Our understanding of the problem is that an initializer from the libstdc++ is
run by the host binary, updating locale::_S_once from the host. Then the shared
libray initializes itself, calls the same initializer through its
non-interposed version, checks the interposed symbol locale::_S_once (remember
we only have -Bsymbolic-functions and not -Bsymbolic), decides everything is
initialized, and proceeds to call a local function that references local
storage that's not initialized, kaboom.
Given the setup, I'm not quite sure libstdc++ should actually support the
scenario, but maybe there's a way?