Skip to content

Commit d3f39ce

Browse files
miss-islingtonChuBoningambv
authored
[3.10] gh-112275: Fix HEAD_LOCK deadlock in child process after fork (GH-112336) (#123687)
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) Co-authored-by: ChuBoning <102216855+ChuBoning@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent 2e861ac commit d3f39ce

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
Lines changed: 3 additions & 0 deletions
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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,11 @@ PyOS_AfterFork_Child(void)
598598
goto fatal_error;
599599
}
600600

601+
status = _PyRuntimeState_ReInitThreads(runtime);
602+
if (_PyStatus_EXCEPTION(status)) {
603+
goto fatal_error;
604+
}
605+
601606
PyThreadState *tstate = _PyThreadState_GET();
602607
_Py_EnsureTstateNotNULL(tstate);
603608

@@ -613,11 +618,6 @@ PyOS_AfterFork_Child(void)
613618

614619
_PySignal_AfterFork();
615620

616-
status = _PyRuntimeState_ReInitThreads(runtime);
617-
if (_PyStatus_EXCEPTION(status)) {
618-
goto fatal_error;
619-
}
620-
621621
status = _PyInterpreterState_DeleteExceptMain(runtime);
622622
if (_PyStatus_EXCEPTION(status)) {
623623
goto fatal_error;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy