From: Jason Fried Date: Mon, 22 May 2017 23:58:55 +0000 (-0700) Subject: bpo-30395 _PyGILState_Reinit deadlock fix (#1734) X-Git-Tag: v3.7.0a1~770 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f82c951d1c5416f3550d544e50ff5662d3836e73;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Misc/ACKS b/Misc/ACKS index 098c801fcb0f..b72c40c3330b 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 8e81707c7cc5..52899f124a0a 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)