From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:42:46 +0000 (+0200) Subject: [3.13] gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (GH-119921) ... X-Git-Tag: v3.13.0b2~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d3de7b0edf46cc0f6aed586111464b2ad581f5a;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (GH-119921) (#119939) The GIL may be disabled concurrently with this call so we need to use a relaxed atomic load. (cherry picked from commit f3b89a63cbb6d46e5ed40d5cd9813cdf9189ce35) Co-authored-by: Sam Gross --- diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index bd3ba1225f25..26ede31b1904 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -145,7 +145,8 @@ extern void _PyEval_ReleaseLock(PyInterpreterState *, PyThreadState *, static inline int _PyEval_IsGILEnabled(PyThreadState *tstate) { - return tstate->interp->ceval.gil->enabled != 0; + struct _gil_runtime_state *gil = tstate->interp->ceval.gil; + return _Py_atomic_load_int_relaxed(&gil->enabled) != 0; } // Enable or disable the GIL used by the interpreter that owns tstate, which diff --git a/Tools/tsan/suppressions_free_threading.txt b/Tools/tsan/suppressions_free_threading.txt index 42ab27e6d990..a451c9dd6bed 100644 --- a/Tools/tsan/suppressions_free_threading.txt +++ b/Tools/tsan/suppressions_free_threading.txt @@ -66,7 +66,6 @@ race_top:list_get_item_ref race_top:make_pending_calls race_top:set_add_entry race_top:should_intern_string -race_top:_PyEval_IsGILEnabled race_top:llist_insert_tail race_top:_Py_slot_tp_getattr_hook race_top:add_threadstate