Created attachment 56595 [details] 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?
Don't use -Bsymbolic-functions then? You are actively breaking the C++ standard guarantees here. Not to say, don't use static linking, but hey ... or at least fully statically link the application.
Writeup about this: https://hacks.mozilla.org/2024/01/option-soup-the-subtle-pitfalls-of-combining-compiler-flags/.