summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-03-21 18:48:40 (GMT)
committerGitHub <noreply@github.com>2025-03-21 18:48:40 (GMT)
commit94fbe97bbef374e240decc8a69107a639151ba02 (patch)
tree79c1b7671f9a1e14276d965376dfa511b11f3f50 /Python
parent55fb3a75d5558c2a1683fd7ca61a320caf24c626 (diff)
downloadcpython-94fbe97bbef374e240decc8a69107a639151ba02.zip
cpython-94fbe97bbef374e240decc8a69107a639151ba02.tar.gz
cpython-94fbe97bbef374e240decc8a69107a639151ba02.tar.bz2
[3.13] gh-117657: Fix TSAN data race in _PyEval_SetTrace assertion (gh-131561) (#131564)
The `sys_tracing_threads` variable should be read inside `LOCK_SETUP()`. (cherry picked from commit 0de5e0c5442abddbe17481ef450e4abc992058f5) Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/legacy_tracing.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c
index 9cc3af1..8a9ad36 100644
--- a/Python/legacy_tracing.c
+++ b/Python/legacy_tracing.c
@@ -596,10 +596,10 @@ _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg)
if (_PySys_Audit(current_tstate, "sys.settrace", NULL) < 0) {
return -1;
}
- assert(tstate->interp->sys_tracing_threads >= 0);
// needs to be decref'd outside of the lock
PyObject *old_traceobj;
LOCK_SETUP();
+ assert(tstate->interp->sys_tracing_threads >= 0);
Py_ssize_t tracing_threads = setup_tracing(tstate, func, arg, &old_traceobj);
UNLOCK_SETUP();
Py_XDECREF(old_traceobj);