From de798204fab798198e7799ed3f2094b63a4c336f Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 23 Jul 2024 19:04:31 +0000 Subject: [PATCH 1/2] gh-117657: Avoid race in `PAUSE_ADAPTIVE_COUNTER` in free-threaded build 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. --- Python/ceval_macros.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index 595b72bfaf9613..d35ea3d190a009 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -316,17 +316,18 @@ GETITEM(PyObject *v, Py_ssize_t i) { /* gh-115999 tracks progress on addressing this. */ \ static_assert(0, "The specializing interpreter is not yet thread-safe"); \ } while (0); +#define PAUSE_ADAPTIVE_COUNTER(COUNTER) ((void)COUNTER) #else #define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \ do { \ (COUNTER) = advance_backoff_counter((COUNTER)); \ } while (0); -#endif #define PAUSE_ADAPTIVE_COUNTER(COUNTER) \ do { \ (COUNTER) = pause_backoff_counter((COUNTER)); \ } while (0); +#endif #define UNBOUNDLOCAL_ERROR_MSG \ "cannot access local variable '%s' where it is not associated with a value" From 5d99792d25ca11cd023b59b633b71344be04dd84 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 23 Jul 2024 19:17:53 +0000 Subject: [PATCH 2/2] Remove _PyEval_EvalFrameDefault suppression --- Tools/tsan/suppressions_free_threading.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Tools/tsan/suppressions_free_threading.txt b/Tools/tsan/suppressions_free_threading.txt index 0955387dfb8370..4a70a3087e5912 100644 --- a/Tools/tsan/suppressions_free_threading.txt +++ b/Tools/tsan/suppressions_free_threading.txt @@ -23,7 +23,6 @@ race:free_threadstate # These warnings trigger directly in a CPython function. -race_top:_PyEval_EvalFrameDefault race_top:assign_version_tag race_top:new_reference race_top:_multiprocessing_SemLock_acquire_impl