summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Fried <me@jasonfried.info>2017-05-22 23:58:55 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2017-05-22 23:58:55 (GMT)
commitf82c951d1c5416f3550d544e50ff5662d3836e73 (patch)
tree3eece5da20e79b1c3376d0186dda931a9951c515
parent1b9530c536664276ce866ae602ce04adce0810e1 (diff)
downloadcpython-f82c951d1c5416f3550d544e50ff5662d3836e73.zip
cpython-f82c951d1c5416f3550d544e50ff5662d3836e73.tar.gz
cpython-f82c951d1c5416f3550d544e50ff5662d3836e73.tar.bz2
bpo-30395 _PyGILState_Reinit deadlock fix (#1734)
head_lock could be held by another thread when fork happened. We should reset it to avoid deadlock.
-rw-r--r--Misc/ACKS1
-rw-r--r--Python/pystate.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/Misc/ACKS b/Misc/ACKS
index 098c801..b72c40c 100644
--- 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
diff --git a/Python/pystate.c b/Python/pystate.c
index 8e81707..52899f1 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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)