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.
This commit is contained in:
Jason Fried 2017-05-22 16:58:55 -07:00 committed by Łukasz Langa
parent 1b9530c536
commit f82c951d1c
2 changed files with 5 additions and 0 deletions

View file

@ -556,6 +556,7 @@ Eric Groo
Daniel Andrade Groppe Daniel Andrade Groppe
Dag Gruneau Dag Gruneau
Filip Gruszczyński Filip Gruszczyński
Andrii Grynenko
Grzegorz Grzywacz Grzegorz Grzywacz
Thomas Guettler Thomas Guettler
Yuyang Guo Yuyang Guo

View file

@ -744,6 +744,10 @@ _PyGILState_Fini(void)
void void
_PyGILState_Reinit(void) _PyGILState_Reinit(void)
{ {
#ifdef WITH_THREAD
head_mutex = NULL;
HEAD_INIT();
#endif
PyThreadState *tstate = PyGILState_GetThisThreadState(); PyThreadState *tstate = PyGILState_GetThisThreadState();
PyThread_delete_key(autoTLSkey); PyThread_delete_key(autoTLSkey);
if ((autoTLSkey = PyThread_create_key()) == -1) if ((autoTLSkey = PyThread_create_key()) == -1)