diff --git a/Misc/NEWS.d/next/Library/2021-06-16-16-52-14.bpo-44434.SQS4Pg.rst b/Misc/NEWS.d/next/Library/2021-06-16-16-52-14.bpo-44434.SQS4Pg.rst new file mode 100644 index 000000000000000..37b5b57ce65693f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-06-16-16-52-14.bpo-44434.SQS4Pg.rst @@ -0,0 +1,4 @@ +_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_exit() aborts the whole process if dlopen() fails to open +libgcc_s.so file (ex: EMFILE error). Patch by Victor Stinner. diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 3f7f1d23bc90dac..cf2443e0fe9a111 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -1107,7 +1107,9 @@ thread_run(void *boot_raw) 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 *