gh-129824: Fix data race on runtime->gilstate.check_enabled (gh-143530)

This commit is contained in:
Sam Gross 2026-01-07 17:56:14 -05:00 committed by GitHub
parent 228d95582e
commit f11f5ebfe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -2435,7 +2435,7 @@ new_interpreter(PyThreadState **tstate_p,
/* Issue #10915, #15751: The GIL API doesn't work with multiple
interpreters: disable PyGILState_Check(). */
runtime->gilstate.check_enabled = 0;
_Py_atomic_store_int_relaxed(&runtime->gilstate.check_enabled, 0);
// XXX Might new_interpreter() have been called without the GIL held?
PyThreadState *save_tstate = _PyThreadState_GET();

View file

@ -2832,7 +2832,7 @@ int
PyGILState_Check(void)
{
_PyRuntimeState *runtime = &_PyRuntime;
if (!runtime->gilstate.check_enabled) {
if (!_Py_atomic_load_int_relaxed(&runtime->gilstate.check_enabled)) {
return 1;
}