https://github.com/python/cpython/commit/f11f5ebfe6614de23918e2c0b7eedb3a12a14752
commit: f11f5ebfe6614de23918e2c0b7eedb3a12a14752
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2026-01-07T17:56:14-05:00
summary:
gh-129824: Fix data race on `runtime->gilstate.check_enabled` (gh-143530)
files:
M Python/pylifecycle.c
M Python/pystate.c
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 16fb43ea191439..88dbdb6d139c5f 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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();
diff --git a/Python/pystate.c b/Python/pystate.c
index f605527598a86d..23853f69792450 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]