8000 gh-117657: Fix race data race in `_Py_IsOwnedByCurrentThread()` (#118… · python/cpython@a5eeb83 · GitHub
[go: up one dir, main page]

Skip to content

Commit a5eeb83

Browse files
authored
gh-117657: Fix race data race in _Py_IsOwnedByCurrentThread() (#118258)
1 parent 5a4d3df commit a5eeb83

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Include/object.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ _Py_ThreadId(void)
303303
static inline Py_ALWAYS_INLINE int
304304
_Py_IsOwnedByCurrentThread(PyObject *ob)
305305
{
306+
#ifdef _Py_THREAD_SANITIZER
307+
return _Py_atomic_load_uintptr_relaxed(&ob->ob_tid) == _Py_ThreadId();
308+
#else
306309
return ob->ob_tid == _Py_ThreadId();
310+
#endif
307311
}
308312
#endif
309313

Tools/tsan/suppressions_free_threading.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ race:set_allocator_unlocked
1414
race:_add_to_weak_set
1515
race:_in_weak_set
1616
race:_mi_heap_delayed_free_partial
17-
race:_Py_IsOwnedByCurrentThread
1817
race:_PyEval_EvalFrameDefault
1918
race:_PyFunction_SetVersion
2019
race:_PyImport_AcquireLock

0 commit comments

Comments
 (0)
0