diff options
author | Łukasz Langa <lukasz@langa.pl> | 2017-05-23 05:23:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-23 05:23:05 (GMT) |
commit | d29feccec3ce3dcd9ab3100f8956171c70ec3027 (patch) | |
tree | 20d4b6ea09a7663a3bae3313f6ca96f109258d92 | |
parent | 1398b1bc7d80df5bde17041e7ec0a3bdbf54b19e (diff) | |
download | cpython-d29feccec3ce3dcd9ab3100f8956171c70ec3027.zip cpython-d29feccec3ce3dcd9ab3100f8956171c70ec3027.tar.gz cpython-d29feccec3ce3dcd9ab3100f8956171c70ec3027.tar.bz2 |
[3.6] bpo-30395 _PyGILState_Reinit deadlock fix (GH-1734) (#1740)
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
(cherry picked from commit f82c951d1c5416f3550d544e50ff5662d3836e73)
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Python/pystate.c | 4 |
2 files changed, 5 insertions, 0 deletions
@@ -552,6 +552,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 65c244e..ccb0092 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -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) |