Skip to content

Commit

Permalink
bpo-30395 _PyGILState_Reinit deadlock fix (#1734)
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.
  • Loading branch information
fried authored and ambv committed May 22, 2017
1 parent 1b9530c commit f82c951
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 @@ -556,6 +556,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 @@ -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)
Expand Down

0 comments on commit f82c951

Please sign in to comment.