]> granicus.if.org Git - python/commitdiff
[3.6] bpo-30395 _PyGILState_Reinit deadlock fix (GH-1734) (#1740)
authorŁukasz Langa <lukasz@langa.pl>
Tue, 23 May 2017 05:23:05 +0000 (22:23 -0700)
committerGitHub <noreply@github.com>
Tue, 23 May 2017 05:23:05 +0000 (22:23 -0700)
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
(cherry picked from commit f82c951d1c5416f3550d544e50ff5662d3836e73)

Misc/ACKS
Python/pystate.c

index 7109ccbe851384d4c08bb38db39a95e2728739a7..b8bac248d988673332140e75db2bcccb7dc390d8 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -552,6 +552,7 @@ Eric Groo
 Daniel Andrade Groppe
 Dag Gruneau
 Filip Gruszczyński
+Andrii Grynenko
 Grzegorz Grzywacz
 Thomas Guettler
 Yuyang Guo
index 65c244e6f736173e21a12f220f3c743a5d960695..ccb0092c42b3a4238b5ea8097e608f6c7a747a4f 100644 (file)
@@ -743,6 +743,10 @@ _PyGILState_Fini(void)
 void
 _PyGILState_Reinit(void)
 {
+#ifdef WITH_THREAD
+    head_mutex = NULL;
+    HEAD_INIT();
+#endif
     PyThreadState *tstate = PyGILState_GetThisThreadState();
     PyThread_delete_key(autoTLSkey);
     if ((autoTLSkey = PyThread_create_key()) == -1)