This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Core interpreter should be linked with libgcc_s.so on Linux
Type: crash Stage: resolved
Components: Interpreter Core Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: _thread module: Remove redundant PyThread_exit_thread() call to avoid glibc fatal error: libgcc_s.so.1 must be installed for pthread_cancel to work
View: 44434
Assigned To: Nosy List: vstinner, zwol
Priority: normal Keywords:

Created on 2019-06-25 01:09 by zwol, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg346468 - (view) Author: Zack Weinberg (zwol) * Date: 2019-06-25 01:09
There are several existing issues (e.g. #18748 and #35866) where at least part of the problem is that GNU libc tried to dlopen() `libgcc_s.so` at a moment when that's not safe, e.g. during thread or process shutdown.  This converts a recoverable error into a deadlock or crash.

This is arguably a bug in glibc, but Python can easily work around it by linking the core interpreter (the `python` executable and/or `libpython.so`) with libgcc_s at build time (`-lgcc_s`) on Linux.  It will then be loaded already if and when it's needed, and glibc won't try to load it on demand.

In order for this to be 100% reliable, it needs to be at least theoretically possible for code within the interpreter to call a function defined in libgcc_s.so. `_Unwind_Backtrace` is probably the most practical option.  (See https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/baselib--unwind-backtrace.html .)
msg396677 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-28 23:47
> This is arguably a bug in glibc, but Python can easily work around it by linking the core interpreter (the `python` executable and/or `libpython.so`) with libgcc_s at build time (`-lgcc_s`) on Linux.  It will then be loaded already if and when it's needed, and glibc won't try to load it on demand.

I fixed the issue differently in bpo-44434.

I mark this issue as a duplicate of bpo-44434.
History
Date User Action Args
2022-04-11 14:59:17adminsetgithub: 81576
2021-06-28 23:47:01vstinnersetstatus: open -> closed

superseder: _thread module: Remove redundant PyThread_exit_thread() call to avoid glibc fatal error: libgcc_s.so.1 must be installed for pthread_cancel to work

nosy: + vstinner
messages: + msg396677
resolution: duplicate
stage: resolved
2019-06-25 01:09:57zwolcreate