From a2ac8e72c6c7c9cecfcc1020e88a4a4a6d4aa32c Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Tue, 11 Mar 2025 09:06:41 +0000 Subject: [PATCH] Check for immortality in refcount accounting --- Include/refcount.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Include/refcount.h b/Include/refcount.h index 88918409d934f6..e66e4aaace3140 100644 --- a/Include/refcount.h +++ b/Include/refcount.h @@ -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 @@ -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); } @@ -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); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy