Skip to content

Commit e742f99

Browse files
miss-islingtonambvChuBoning
authored
[3.8] gh-112275: Fix HEAD_LOCK deadlock in child process after fork (GH-112336) (GH-123688) (#123713)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork. (cherry picked from commit 522799a) (cherry picked from commit 0152431) Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: ChuBoning <102216855+ChuBoning@users.noreply.github.com>
1 parent 2309739 commit e742f99

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
A deadlock involving ``pystate.c``'s ``HEAD_LOCK`` in ``posixmodule.c``
2+
at fork is now fixed. Patch by ChuBoning based on previous Python 3.12
3+
fix by Victor Stinner.

Modules/posixmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,10 @@ PyOS_AfterFork_Child(void)
472472
{
473473
_PyRuntimeState *runtime = &_PyRuntime;
474474
_PyGILState_Reinit(runtime);
475+
_PyRuntimeState_ReInitThreads(runtime);
475476
_PyEval_ReInitThreads(runtime);
476477
_PyImport_ReInitLock();
477478
_PySignal_AfterFork();
478-
_PyRuntimeState_ReInitThreads(runtime);
479479
_PyInterpreterState_DeleteExceptMain(runtime);
480480

481481
run_at_forkers(_PyInterpreterState_Get()->after_forkers_child, 0);

0 commit comments

Comments
 (0)