Skip to content

Commit f82c951

Browse files
friedambv
authored andcommitted
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.
1 parent 1b9530c commit f82c951

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ Eric Groo
556556
Daniel Andrade Groppe
557557
Dag Gruneau
558558
Filip Gruszczyński
559+
Andrii Grynenko
559560
Grzegorz Grzywacz
560561
Thomas Guettler
561562
Yuyang Guo

Python/pystate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@ _PyGILState_Fini(void)
744744
void
745745
_PyGILState_Reinit(void)
746746
{
747+
#ifdef WITH_THREAD
748+
head_mutex = NULL;
749+
HEAD_INIT();
750+
#endif
747751
PyThreadState *tstate = PyGILState_GetThisThreadState();
748752
PyThread_delete_key(autoTLSkey);
749753
if ((autoTLSkey = PyThread_create_key()) == -1)

0 commit comments

Comments
 (0)