Kaydet (Commit) b5409dac authored tarafından Stéphane Wirtel's avatar Stéphane Wirtel Kaydeden (comit) Victor Stinner

bpo-35993: Fix _PyInterpreterState_DeleteExceptMain() (GH-11852)

 Fix a crash on fork when using subinterpreters.
üst 001fee14
Fix a crash on fork when using subinterpreters. Contributed by Stéphane Wirtel
...@@ -281,10 +281,11 @@ _PyInterpreterState_DeleteExceptMain() ...@@ -281,10 +281,11 @@ _PyInterpreterState_DeleteExceptMain()
HEAD_LOCK(); HEAD_LOCK();
PyInterpreterState *interp = _PyRuntime.interpreters.head; PyInterpreterState *interp = _PyRuntime.interpreters.head;
_PyRuntime.interpreters.head = NULL; _PyRuntime.interpreters.head = NULL;
for (; interp != NULL; interp = interp->next) { while (interp != NULL) {
if (interp == _PyRuntime.interpreters.main) { if (interp == _PyRuntime.interpreters.main) {
_PyRuntime.interpreters.main->next = NULL; _PyRuntime.interpreters.main->next = NULL;
_PyRuntime.interpreters.head = interp; _PyRuntime.interpreters.head = interp;
interp = interp->next;
continue; continue;
} }
...@@ -293,7 +294,9 @@ _PyInterpreterState_DeleteExceptMain() ...@@ -293,7 +294,9 @@ _PyInterpreterState_DeleteExceptMain()
if (interp->id_mutex != NULL) { if (interp->id_mutex != NULL) {
PyThread_free_lock(interp->id_mutex); PyThread_free_lock(interp->id_mutex);
} }
PyMem_RawFree(interp); PyInterpreterState *prev_interp = interp;
interp = interp->next;
PyMem_RawFree(prev_interp);
} }
HEAD_UNLOCK(); HEAD_UNLOCK();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment