Skip to content

Commit 8e96d85

Browse files
[3.13] gh-117657: Avoid race in PAUSE_ADAPTIVE_COUNTER in free-threaded build (GH-122190) (#122475)
The adaptive counter doesn't do anything currently in the free-threaded build and TSan reports a data race due to concurrent modifications to the counter. (cherry picked from commit 2b163aa) Co-authored-by: Sam Gross <[email protected]>
1 parent 1912f94 commit 8e96d85

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Python/ceval_macros.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,18 @@ GETITEM(PyObject *v, Py_ssize_t i) {
314314
/* gh-115999 tracks progress on addressing this. */ \
315315
static_assert(0, "The specializing interpreter is not yet thread-safe"); \
316316
} while (0);
317+
#define PAUSE_ADAPTIVE_COUNTER(COUNTER) ((void)COUNTER)
317318
#else
318319
#define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \
319320
do { \
320321
(COUNTER) = advance_backoff_counter((COUNTER)); \
321322
} while (0);
322-
#endif
323323

324324
#define PAUSE_ADAPTIVE_COUNTER(COUNTER) \
325325
do { \
326326
(COUNTER) = pause_backoff_counter((COUNTER)); \
327327
} while (0);
328+
#endif
328329

329330
#define UNBOUNDLOCAL_ERROR_MSG \
330331
"cannot access local variable '%s' where it is not associated with a value"

Tools/tsan/suppressions_free_threading.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ race:free_threadstate
2323

2424
# These warnings trigger directly in a CPython function.
2525

26-
race_top:_PyEval_EvalFrameDefault
2726
race_top:assign_version_tag
2827
race_top:new_reference
2928
race_top:_multiprocessing_SemLock_acquire_impl

0 commit comments

Comments
 (0)