summaryrefslogtreecommitdiff
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-06-21 14:22:56 +0200
committerGitHub <noreply@github.com>2021-06-21 14:22:56 +0200
commit83ad40efc3e299d1e94692d958111a63c2fd6775 (patch)
tree129812c6267b6d0e9bc483a3bbb452b8b6f929d5 /Modules/_threadmodule.c
parent175e264d363164c905b08688bbda751c9ff26342 (diff)
downloadcpython-git-83ad40efc3e299d1e94692d958111a63c2fd6775.tar.gz
bpo-44434: Don't call PyThread_exit_thread() explicitly (GH-26758) (GH-26825)
_thread.start_new_thread() no longer calls PyThread_exit_thread() explicitly at the thread exit, the call was redundant. On Linux with the glibc, pthread_cancel() loads dynamically the libgcc_s.so.1 library. dlopen() can fail if there is no more available file descriptor to open the file. In this case, the process aborts with the error message: "libgcc_s.so.1 must be installed for pthread_cancel to work" pthread_cancel() unwinds back to the thread's wrapping function that calls the thread entry point. The unwind function is dynamically loaded from the libgcc_s library since it is tightly coupled to the C compiler (GCC). The unwinder depends on DWARF, the compiler generates DWARF, so the unwinder belongs to the compiler. Thanks Florian Weimer and Carlos O'Donell for their help on investigating this issue. (cherry picked from commit 45a78f906d2d5fe5381d78466b11763fc56d57ba)
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r--Modules/_threadmodule.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 77baba4847..a370352238 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -1056,7 +1056,10 @@ t_bootstrap(void *boot_raw)
tstate->interp->num_threads--;
PyThreadState_Clear(tstate);
_PyThreadState_DeleteCurrent(tstate);
- PyThread_exit_thread();
+
+ // bpo-44434: Don't call explicitly PyThread_exit_thread(). On Linux with
+ // the glibc, pthread_exit() can abort the whole process if dlopen() fails
+ // to open the libgcc_s.so library (ex: EMFILE error).
}
static PyObject *