Closed
Description
Bug report
There is a subtle possible race condition in _Py_ExplicitMergeRefcount
: we set ob_ref_local
and ob_tid
to zero after writing the merged refcount to ob_ref_shared
.
That's not safe, because another thread might possibly deallocate the object after we merged refcount. For example:
- Assume that the merged refcount is
1
- Some other thread calls
Py_DECREF()
and immediately frees the object - We write zero to
ob_ref_local
andob_tid
-- BUG!
Lines 413 to 422 in 41c1cef