]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36333, bpo-36356: Fix _PyEval_FiniThreads() (GH-12432)
authorVictor Stinner <vstinner@redhat.com>
Tue, 19 Mar 2019 13:19:38 +0000 (14:19 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Mar 2019 13:19:38 +0000 (14:19 +0100)
_PyEval_FiniThreads() now free the pending lock.

Python/ceval.c

index d6a0b335955e0982eb3583bc0d9e4522400ca523..40320bf357030480b69365012d250830515b3ad6 100644 (file)
@@ -169,8 +169,10 @@ PyEval_ThreadsInitialized(void)
 void
 PyEval_InitThreads(void)
 {
-    if (gil_created())
+    if (gil_created()) {
         return;
+    }
+
     PyThread_init_thread();
     create_gil();
     take_gil(_PyThreadState_GET());
@@ -184,10 +186,17 @@ PyEval_InitThreads(void)
 void
 _PyEval_FiniThreads(void)
 {
-    if (!gil_created())
+    if (!gil_created()) {
         return;
+    }
+
     destroy_gil();
     assert(!gil_created());
+
+    if (_PyRuntime.ceval.pending.lock != NULL) {
+        PyThread_free_lock(_PyRuntime.ceval.pending.lock);
+        _PyRuntime.ceval.pending.lock = NULL;
+    }
 }
 
 void