Skip to content

Commit f11f5eb

Browse files
authored
pythongh-129824: Fix data race on runtime->gilstate.check_enabled (pythongh-143530)
1 parent 228d955 commit f11f5eb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Python/pylifecycle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ new_interpreter(PyThreadState **tstate_p,
24352435

24362436
/* Issue #10915, #15751: The GIL API doesn't work with multiple
24372437
interpreters: disable PyGILState_Check(). */
2438-
runtime->gilstate.check_enabled = 0;
2438+
_Py_atomic_store_int_relaxed(&runtime->gilstate.check_enabled, 0);
24392439

24402440
// XXX Might new_interpreter() have been called without the GIL held?
24412441
PyThreadState *save_tstate = _PyThreadState_GET();

Python/pystate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ int
28322832
PyGILState_Check(void)
28332833
{
28342834
_PyRuntimeState *runtime = &_PyRuntime;
2835-
if (!runtime->gilstate.check_enabled) {
2835+
if (!_Py_atomic_load_int_relaxed(&runtime->gilstate.check_enabled)) {
28362836
return 1;
28372837
}
28382838

0 commit comments

Comments
 (0)