]> granicus.if.org Git - python/commitdiff
bpo-30395 _PyGILState_Reinit deadlock fix (#1734)
authorJason Fried <me@jasonfried.info>
Mon, 22 May 2017 23:58:55 +0000 (16:58 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Mon, 22 May 2017 23:58:55 +0000 (16:58 -0700)
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.

Misc/ACKS
Python/pystate.c

index 098c801fcb0fc914626845abac481b9ac49114d8..b72c40c3330bc21868c36af89dde4bb4121c078a 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -556,6 +556,7 @@ Eric Groo
 Daniel Andrade Groppe
 Dag Gruneau
 Filip Gruszczyński
+Andrii Grynenko
 Grzegorz Grzywacz
 Thomas Guettler
 Yuyang Guo
index 8e81707c7cc559d7604df549069963dacfdd4e06..52899f124a0aba8f2c6b7690fb9c0faaebb6ef2c 100644 (file)
@@ -744,6 +744,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)