8000 GH-127705: Check for immortality in refcount accounting (#131072) · python/cpython@6e5b9f3 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6e5b9f3

Browse files
authored
GH-127705: Check for immortality in refcount accounting (#131072)
Check for immortality in refcount accounting
1 parent de8818a commit 6e5b9f3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Include/refcount.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ static inline Py_ALWAYS_INLINE void Py_INCREF_MORTAL(PyObject *op)
249249
op->ob_refcnt++;
250250
_Py_INCREF_STAT_INC();
251251
#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)
252-
_Py_INCREF_IncRefTotal();
252+
if (!_Py_IsImmortal(op)) {
253+
_Py_INCREF_IncRefTotal();
254+
}
253255
#endif
254256
}
255257
#endif
@@ -391,7 +393,9 @@ static inline void Py_DECREF_MORTAL(const char *filename, int lineno, PyObject *
391393
}
392394
_Py_DECREF_STAT_INC();
393395
assert(!_Py_IsStaticImmortal(op));
394-
_Py_DECREF_DecRefTotal();
396+
if (!_Py_IsImmortal(op)) {
397+
_Py_DECREF_DecRefTotal();
398+
}
395399
if (--op->ob_refcnt == 0) {
396400
_Py_Dealloc(op);
397401
}
@@ -407,7 +411,9 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
407411
}
408412
_Py_DECREF_STAT_INC();
409413
assert(!_Py_IsStaticImmortal(op));
410-
_Py_DECREF_DecRefTotal();
414+
if (!_Py_IsImmortal(op)) {
415+
_Py_DECREF_DecRefTotal();
416+
}
411417
if (--op->ob_refcnt == 0) {
412418
destruct(op);
413419
}

0 commit comments

Comments
 (0)
0