Skip to content

Commit adb985f

Browse files
committed
Do the compare-exchange under the head lock.
1 parent c5148d1 commit adb985f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Python/pylifecycle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,18 +2359,18 @@ make_pre_finalization_calls(PyThreadState *tstate, int subinterpreters)
23592359
|| interp_has_atexit_callbacks(interp)
23602360
|| interp_has_pending_calls(interp)
23612361
|| has_subinterpreters);
2362-
HEAD_UNLOCK(interp->runtime);
23632362

23642363
if (!should_continue) {
23652364
// We only want to prevent new guards once we're sure that we
23662365
// won't be running another pre-finalization cycle.
23672366
if (_Py_atomic_compare_exchange_uintptr(&interp->finalization_guards,
23682367
&guards_expected,
23692368
_PyInterpreterGuard_GUARDS_NOT_ALLOWED) == 1) {
2369+
HEAD_UNLOCK(interp->runtime);
23702370
break;
23712371
}
23722372
}
2373-
2373+
HEAD_UNLOCK(interp->runtime);
23742374
_PyEval_StartTheWorldAll(interp->runtime);
23752375
PyMutex_Unlock(&interp->ceval.pending.mutex);
23762376
}

0 commit comments

Comments
 (0)