Consider building with -fPIC
by default on Linux, due to conflict with RTLD_DEEPBIND
#116015
Labels
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
Shared libraries that depend on GCC's
libgomp
v13 fail to load in Python if the executable was linked without-fPIC
:The problem here is that
libgomp.so
ends up accessing an uninitialized copy of a symbol in libc (specificallyenviron
).When Python is linked without
-fPIC
, the linker introduces a copy ofenviron
in the executable.bss
section. This copy is what is used by the executable and most libraries, but libraries loaded withRTLD_DEEPBIND
do not resolve to it. They instead encounter the original (uninitialized) symbol in libc, triggering this segfault.See also https://stackoverflow.com/a/34074587 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111556, along with downstream issues JuliaLang/julia#53363 (comment) and conda-forge/ctng-compilers-feedstock#114
Note: Before GCC 13,
libgomp
did not access theenviron
symbol in libc so it wasn't sensitive to this kind of linker problem. However, since GCC 13, it does access this symbol and assumes that it has been initialized by libc.CPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: