]> granicus.if.org Git - python/commitdiff
bpo-37031: Fix PyOS_AfterFork_Child() (GH-13537)
authorVictor Stinner <vstinner@redhat.com>
Fri, 24 May 2019 13:20:23 +0000 (15:20 +0200)
committerGitHub <noreply@github.com>
Fri, 24 May 2019 13:20:23 +0000 (15:20 +0200)
PyOS_AfterFork_Child(): _PyInterpreterState_DeleteExceptMain() must
be called after _PyRuntimeState_ReInitThreads().

_PyRuntimeState_ReInitThreads() resets interpreters mutex after fork,
mutex used by _PyInterpreterState_DeleteExceptMain().

Modules/posixmodule.c

index 8ebe3a0be05350191810f25fac351ab03ab4423e..cd5b5ce082ece4209bfd251b85362166f3a0456e 100644 (file)
@@ -448,11 +448,11 @@ PyOS_AfterFork_Child(void)
 {
     _PyRuntimeState *runtime = &_PyRuntime;
     _PyGILState_Reinit(runtime);
-    _PyInterpreterState_DeleteExceptMain(runtime);
     _PyEval_ReInitThreads(runtime);
     _PyImport_ReInitLock();
     _PySignal_AfterFork();
     _PyRuntimeState_ReInitThreads(runtime);
+    _PyInterpreterState_DeleteExceptMain(runtime);
 
     run_at_forkers(_PyInterpreterState_Get()->after_forkers_child, 0);
 }