Skip to content

Commit 2b163aa

Browse files
authored
gh-117657: Avoid race in PAUSE_ADAPTIVE_COUNTER in free-threaded build (#122190)
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.
1 parent 1d8e453 commit 2b163aa

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
@@ -316,17 +316,18 @@ GETITEM(PyObject *v, Py_ssize_t i) {
316316
/* gh-115999 tracks progress on addressing this. */ \
317317
static_assert(0, "The specializing interpreter is not yet thread-safe"); \
318318
} while (0);
319+
#define PAUSE_ADAPTIVE_COUNTER(COUNTER) ((void)COUNTER)
319320
#else
320321
#define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \
321322
do { \
322323
(COUNTER) = advance_backoff_counter((COUNTER)); \
323324
} while (0);
324-
#endif
325325

326326
#define PAUSE_ADAPTIVE_COUNTER(COUNTER) \
327327
do { \
328328
(COUNTER) = pause_backoff_counter((COUNTER)); \
329329
} while (0);
330+
#endif
330331

331332
#define UNBOUNDLOCAL_ERROR_MSG \
332333
"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)