Skip to content

Commit

Permalink
[3.6] bpo-30395 _PyGILState_Reinit deadlock fix (GH-1734) (#1740)
Browse files Browse the repository at this point in the history
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
(cherry picked from commit f82c951)
  • Loading branch information
ambv committed May 23, 2017
1 parent 1398b1b commit d29fecc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ Eric Groo
Daniel Andrade Groppe
Dag Gruneau
Filip Gruszczyński
Andrii Grynenko
Grzegorz Grzywacz
Thomas Guettler
Yuyang Guo
Expand Down
4 changes: 4 additions & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d29fecc

Please sign in to comment.