Skip to content

Commit f14e9f9

Browse files
authored
gh-117657: Fix data race in _Py_IsImmortal (#118261)
The load of `ob_ref_local races with stores. Using a relaxed load is sufficient; stores to the field are relaxed.
1 parent fb7f79b commit f14e9f9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Include/object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ static inline Py_ssize_t Py_SIZE(PyObject *ob) {
349349
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
350350
{
351351
#if defined(Py_GIL_DISABLED)
352-
return (op->ob_ref_local == _Py_IMMORTAL_REFCNT_LOCAL);
352+
return (_Py_atomic_load_uint32_relaxed(&op->ob_ref_local) ==
353+
_Py_IMMORTAL_REFCNT_LOCAL);
353354
#elif SIZEOF_VOID_P > 4
354355
return (_Py_CAST(PY_INT32_T, op->ob_refcnt) < 0);
355356
#else

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_IsImmortal
1817
race:_Py_IsOwnedByCurrentThread
1918
race:_PyEval_EvalFrameDefault
2019
race:_PyFunction_SetVersion

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy