|
|
4d7d43 |
bpo-44434: Don't call PyThread_exit_thread() explicitly (GH-26758)
|
|
|
4d7d43 |
|
|
|
4d7d43 |
_thread.start_new_thread() no longer calls PyThread_exit_thread()
|
|
|
4d7d43 |
explicitly at the thread exit, the call was redundant.
|
|
|
4d7d43 |
|
|
|
4d7d43 |
On Linux with the glibc, pthread_cancel() loads dynamically the
|
|
|
4d7d43 |
libgcc_s.so.1 library. dlopen() can fail if there is no more
|
|
|
4d7d43 |
available file descriptor to open the file. In this case, the process
|
|
|
4d7d43 |
aborts with the error message:
|
|
|
4d7d43 |
|
|
|
4d7d43 |
"libgcc_s.so.1 must be installed for pthread_cancel to work"
|
|
|
4d7d43 |
|
|
|
4d7d43 |
pthread_cancel() unwinds back to the thread's wrapping function that
|
|
|
4d7d43 |
calls the thread entry point.
|
|
|
4d7d43 |
|
|
|
4d7d43 |
The unwind function is dynamically loaded from the libgcc_s library
|
|
|
4d7d43 |
since it is tightly coupled to the C compiler (GCC). The unwinder
|
|
|
4d7d43 |
depends on DWARF, the compiler generates DWARF, so the unwinder
|
|
|
4d7d43 |
belongs to the compiler.
|
|
|
4d7d43 |
|
|
|
4d7d43 |
Thanks Florian Weimer and Carlos O'Donell for their help on
|
|
|
4d7d43 |
investigating this issue.
|
|
|
4d7d43 |
|
|
|
4d7d43 |
https://github.com/python/cpython/commit/45a78f906d2d5fe5381d78466b11763fc56d57ba
|
|
|
4d7d43 |
|
|
|
4d7d43 |
Resolves: rhbz#1972293
|
|
|
4d7d43 |
|
|
|
4d7d43 |
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
|
|
|
4d7d43 |
index a13b2e0..8cc035b 100644
|
|
|
4d7d43 |
--- a/Modules/_threadmodule.c
|
|
|
4d7d43 |
+++ b/Modules/_threadmodule.c
|
|
|
4d7d43 |
@@ -1027,7 +1027,10 @@ t_bootstrap(void *boot_raw)
|
|
|
4d7d43 |
nb_threads--;
|
|
|
4d7d43 |
PyThreadState_Clear(tstate);
|
|
|
4d7d43 |
PyThreadState_DeleteCurrent();
|
|
|
4d7d43 |
- PyThread_exit_thread();
|
|
|
4d7d43 |
+
|
|
|
4d7d43 |
+ // bpo-44434: Don't call explicitly PyThread_exit_thread(). On Linux with
|
|
|
4d7d43 |
+ // the glibc, pthread_exit() can abort the whole process if dlopen() fails
|
|
|
4d7d43 |
+ // to open the libgcc_s.so library (ex: EMFILE error).
|
|
|
4d7d43 |
}
|
|
|
4d7d43 |
|
|
|
4d7d43 |
static PyObject *
|