mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[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>
This commit is contained in:
parent
851821d871
commit
522799a05e
2 changed files with 8 additions and 5 deletions
|
|
@ -0,0 +1,3 @@
|
|||
A deadlock involving ``pystate.c``'s ``HEAD_LOCK`` in ``posixmodule.c``
|
||||
at fork is now fixed. Patch by ChuBoning based on previous Python 3.12
|
||||
fix by Victor Stinner.
|
||||
|
|
@ -603,6 +603,11 @@ PyOS_AfterFork_Child(void)
|
|||
goto fatal_error;
|
||||
}
|
||||
|
||||
status = _PyRuntimeState_ReInitThreads(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
_Py_EnsureTstateNotNULL(tstate);
|
||||
|
||||
|
|
@ -622,11 +627,6 @@ PyOS_AfterFork_Child(void)
|
|||
|
||||
_PySignal_AfterFork();
|
||||
|
||||
status = _PyRuntimeState_ReInitThreads(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
status = _PyInterpreterState_DeleteExceptMain(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue