]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-119799: Add missing `_Py_IncRefTotal` to `_Py_NewRefWithLock` (#119800)
authorSam Gross <colesbury@gmail.com>
Fri, 31 May 2024 18:18:24 +0000 (14:18 -0400)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 18:18:24 +0000 (14:18 -0400)
The free-threaded refleak builds were reporting negative refcount deltas
in some tests because of a missing `_Py_NewRefWithLock`.

Include/internal/pycore_object.h

index 7602248f956405f5df78504c6adb1842eeadc22c..f63e1da6fba025e0be92de80959a479d2e0f9221 100644 (file)
@@ -497,6 +497,9 @@ _Py_NewRefWithLock(PyObject *op)
     if (_Py_TryIncrefFast(op)) {
         return op;
     }
+#ifdef Py_REF_DEBUG
+    _Py_IncRefTotal(_PyThreadState_GET());
+#endif
     _Py_INCREF_STAT_INC();
     for (;;) {
         Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);