diff options
author | mpage <mpage@meta.com> | 2024-04-26 14:39:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-26 14:39:08 (GMT) |
commit | a5eeb832c2bbbd6ce1e9d545a553de926af468d5 (patch) | |
tree | 6c23800987d3b4f6bded2e46f7840f6964a14846 /Include | |
parent | 5a4d3df2fa02409ffd2a90cd75b67370206e9891 (diff) | |
download | cpython-a5eeb832c2bbbd6ce1e9d545a553de926af468d5.zip cpython-a5eeb832c2bbbd6ce1e9d545a553de926af468d5.tar.gz cpython-a5eeb832c2bbbd6ce1e9d545a553de926af468d5.tar.bz2 |
gh-117657: Fix race data race in `_Py_IsOwnedByCurrentThread()` (#118258)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/object.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h index 5aaf11c..9132784 100644 --- a/Include/object.h +++ b/Include/object.h @@ -303,7 +303,11 @@ _Py_ThreadId(void) static inline Py_ALWAYS_INLINE int _Py_IsOwnedByCurrentThread(PyObject *ob) { +#ifdef _Py_THREAD_SANITIZER + return _Py_atomic_load_uintptr_relaxed(&ob->ob_tid) == _Py_ThreadId(); +#else return ob->ob_tid == _Py_ThreadId(); +#endif } #endif |