Skip to content

GH-127705: Check for immortality in refcount accounting #131072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Include/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ static inline Py_ALWAYS_INLINE void Py_INCREF_MORTAL(PyObject *op)
op->ob_refcnt++;
_Py_INCREF_STAT_INC();
#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)
_Py_INCREF_IncRefTotal();
if (!_Py_IsImmortal(op)) {
_Py_INCREF_IncRefTotal();
}
#endif
}
#endif
Expand Down Expand Up @@ -391,7 +393,9 @@ static inline void Py_DECREF_MORTAL(const char *filename, int lineno, PyObject *
}
_Py_DECREF_STAT_INC();
assert(!_Py_IsStaticImmortal(op));
_Py_DECREF_DecRefTotal();
if (!_Py_IsImmortal(op)) {
_Py_DECREF_DecRefTotal();
}
if (--op->ob_refcnt == 0) {
_Py_Dealloc(op);
}
Expand All @@ -407,7 +411,9 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
}
_Py_DECREF_STAT_INC();
assert(!_Py_IsStaticImmortal(op));
_Py_DECREF_DecRefTotal();
if (!_Py_IsImmortal(op)) {
_Py_DECREF_DecRefTotal();
}
if (--op->ob_refcnt == 0) {
destruct(op);
}
Expand Down
Loading