Skip to content

Commit 9d3de7b

Browse files
[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 f3b89a6) Co-authored-by: Sam Gross <colesbury@gmail.com>
1 parent cf8f292 commit 9d3de7b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Include/internal/pycore_ceval.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ extern void _PyEval_ReleaseLock(PyInterpreterState *, PyThreadState *,
145145
static inline int
146146
_PyEval_IsGILEnabled(PyThreadState *tstate)
147147
{
148-
return tstate->interp->ceval.gil->enabled != 0;
148+
struct _gil_runtime_state *gil = tstate->interp->ceval.gil;
149+
return _Py_atomic_load_int_relaxed(&gil->enabled) != 0;
149150
}
150151

151152
// Enable or disable the GIL used by the interpreter that owns tstate, which

Tools/tsan/suppressions_free_threading.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ race_top:list_get_item_ref
6666
race_top:make_pending_calls
6767
race_top:set_add_entry
6868
race_top:should_intern_string
69-
race_top:_PyEval_IsGILEnabled
7069
race_top:llist_insert_tail
7170
race_top:_Py_slot_tp_getattr_hook
7271
race_top:add_threadstate

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy