Skip to content

Commit 81c2430

Browse files
committed
fix refleaks
1 parent f05fefc commit 81c2430

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

Include/internal/pycore_object.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
262262
return;
263263
}
264264
_Py_DECREF_STAT_INC();
265+
#ifdef Py_REF_DEBUG
266+
_Py_DEC_REFTOTAL(PyInterpreterState_Get());
267+
#endif
265268
if (_Py_IsOwnedByCurrentThread(op)) {
266269
local--;
267270
_Py_atomic_store_uint32_relaxed(&op->ob_ref_local, local);

Objects/object.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ _Py_MergeZeroLocalRefcountSpecialized(PyObject *op, const destructor destruct)
471471

472472
Py_ssize_t shared = _Py_atomic_load_ssize_acquire(&op->ob_ref_shared);
473473
if (shared == 0) {
474+
#ifdef Py_TRACE_REFS
475+
_Py_ForgetReference(op);
476+
#endif
477+
_PyReftracerTrack(op, PyRefTracer_DESTROY);
474478
destruct(op);
475479
return;
476480
}
@@ -484,6 +488,10 @@ _Py_MergeZeroLocalRefcountSpecialized(PyObject *op, const destructor destruct)
484488
&shared, new_shared));
485489

486490
if (new_shared == _Py_REF_MERGED) {
491+
#ifdef Py_TRACE_REFS
492+
_Py_ForgetReference(op);
493+
#endif
494+
_PyReftracerTrack(op, PyRefTracer_DESTROY);
487495
destruct(op);
488496
}
489497
}

0 commit comments

Comments
 (0)