aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/pystate.c
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2024-07-02 22:47:57 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2024-07-02 22:59:47 +0300
commit96b239778766d32d5158aca805e08199b3c0a743 (patch)
treea9c8679261a62138ec4735d878a11f6478cd196a /contrib/tools/python3/Python/pystate.c
parent292e7317266c2136a1e1bd027e16e6eefb639028 (diff)
downloadydb-96b239778766d32d5158aca805e08199b3c0a743.tar.gz
Update contrib/tools/python3 to 3.12.4
6e8edffbef193b35b45ddccdc3beda6bb2627186
Diffstat (limited to 'contrib/tools/python3/Python/pystate.c')
-rw-r--r--contrib/tools/python3/Python/pystate.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/tools/python3/Python/pystate.c b/contrib/tools/python3/Python/pystate.c
index 7acf4f9854..93fbbaaf01 100644
--- a/contrib/tools/python3/Python/pystate.c
+++ b/contrib/tools/python3/Python/pystate.c
@@ -2282,12 +2282,18 @@ PyGILState_Release(PyGILState_STATE oldstate)
/* can't have been locked when we created it */
assert(oldstate == PyGILState_UNLOCKED);
// XXX Unbind tstate here.
+ // gh-119585: `PyThreadState_Clear()` may call destructors that
+ // themselves use PyGILState_Ensure and PyGILState_Release, so make
+ // sure that gilstate_counter is not zero when calling it.
+ ++tstate->gilstate_counter;
PyThreadState_Clear(tstate);
+ --tstate->gilstate_counter;
/* Delete the thread-state. Note this releases the GIL too!
* It's vital that the GIL be held here, to avoid shutdown
* races; see bugs 225673 and 1061968 (that nasty bug has a
* habit of coming back).
*/
+ assert(tstate->gilstate_counter == 0);
assert(current_fast_get(runtime) == tstate);
_PyThreadState_DeleteCurrent(tstate);
}