File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -723,7 +723,7 @@ Py_DECREF(PyObject *op)
723
723
_Py_DECREF_STAT_INC ();
724
724
// Non-limited C API and limited C API for Python 3.9 and older access
725
725
// directly PyObject.ob_refcnt.
726
- uintptr_t tid = op -> ob_tid ;
726
+ uintptr_t tid = _Py_atomic_load_uintptr_relaxed ( & op -> ob_tid ) ;
727
727
if (tid == _Py_STATIC_CAST (uintptr_t , Py_REF_IMMORTAL )) {
728
728
return ;
729
729
}
@@ -736,8 +736,14 @@ Py_DECREF(PyObject *op)
736
736
_Py_NegativeRefcount (filename , lineno , op );
737
737
}
738
738
#endif
739
- op -> ob_ref_local -= (1 << _Py_REF_LOCAL_SHIFT );
740
- if (_PY_UNLIKELY (op -> ob_ref_local == 0 )) {
739
+ uint32_t local = op -> ob_ref_local ;
740
+ local -= (1 << _Py_REF_LOCAL_SHIFT );
741
+ #ifdef _Py_THREAD_SANITIZER
742
+ _Py_atomic_store_uint32_relaxed (& op -> ob_ref_local , local );
743
+ #else
744
+ op -> ob_ref_local = local ;
745
+ #endif
746
+ if (_PY_UNLIKELY (local == 0 )) {
741
747
_Py_MergeZeroRefcount (op );
742
748
}
743
749
}
You can’t perform that action at this time.
0 commit comments