File bpo-44434-libgcc_s-for-pthread_cancel.patch of Package python3.36158
From f9cff839bdbccfc51803aab252ca1cd53220f5a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu>
Date: Thu, 4 Apr 2024 00:32:44 +0200
Subject: [PATCH] don't run PyThread_exit_thread() when you don't have to
Code is from gh#python/cpython@83ad40efc3e and it was released
upstream in 3.9.10.
Fixes: bsc#1203355
Patch: bpo-44434-libgcc_s-for-pthread_cancel.patch
---
Modules/_testcapimodule.c | 2 --
Modules/_threadmodule.c | 5 ++++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 067d46346a6..2559383cdb5 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -3651,8 +3651,6 @@ temporary_c_thread(void *data)
PyGILState_Release(state);
PyThread_release_lock(test_c_thread->exit_event);
-
- PyThread_exit_thread();
}
static PyObject *
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index a13b2e07400..8cc035b2f76 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -1027,7 +1027,10 @@ t_bootstrap(void *boot_raw)
nb_threads--;
PyThreadState_Clear(tstate);
PyThreadState_DeleteCurrent();
- 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 *
--
2.45.0