]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154822: Fix racy assertion during finalization (GH-154824)
authorPeter Bierma <zintensitydev@gmail.com>
Tue, 28 Jul 2026 16:06:52 +0000 (12:06 -0400)
committerGitHub <noreply@github.com>
Tue, 28 Jul 2026 16:06:52 +0000 (12:06 -0400)
Python/pylifecycle.c

index 01ca459b2eb2b8fe79550e90a86c88a1f5dd9869..500a1a1949a5a8a32e418c58f6133a87f35446f1 100644 (file)
@@ -3827,8 +3827,8 @@ handle_thread_shutdown_exception(PyThreadState *tstate)
     assert(tstate != NULL);
     assert(_PyErr_Occurred(tstate));
     PyInterpreterState *interp = tstate->interp;
-    assert(interp->threads.head != NULL);
     _PyEval_StopTheWorld(interp);
+    assert(interp->threads.head != NULL);
 
     // We don't have to worry about locking this because the
     // world is stopped.