Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 522799a

Browse filesBrowse files
ChuBoningambv
andauthored
[3.11]GH-112275: Fix HEAD_LOCK deadlock in child process after fork (#112336)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent 851821d commit 522799a
Copy full SHA for 522799a

File tree

2 files changed

+8
-5
lines changed
Filter options

2 files changed

+8
-5
lines changed
+3Lines 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

Copy file name to clipboardExpand all lines: Modules/posixmodule.c
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,11 @@ PyOS_AfterFork_Child(void)
603603
goto fatal_error;
604604
}
605605

606+
status = _PyRuntimeState_ReInitThreads(runtime);
607+
if (_PyStatus_EXCEPTION(status)) {
608+
goto fatal_error;
609+
}
610+
606611
PyThreadState *tstate = _PyThreadState_GET();
607612
_Py_EnsureTstateNotNULL(tstate);
608613

@@ -622,11 +627,6 @@ PyOS_AfterFork_Child(void)
622627

623628
_PySignal_AfterFork();
624629

625-
status = _PyRuntimeState_ReInitThreads(runtime);
626-
if (_PyStatus_EXCEPTION(status)) {
627-
goto fatal_error;
628-
}
629-
630630
status = _PyInterpreterState_DeleteExceptMain(runtime);
631631
if (_PyStatus_EXCEPTION(status)) {
632632
goto fatal_error;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.