Skip to content

Navigation Menu

Sign in
Appearance settings

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 fdac362

Browse filesBrowse files
authored
[3.13] gh-127599: Fix _Py_RefcntAdd missing calls to _Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC (GH-127717) (#128713)
Previously, `_Py_RefcntAdd` hasn't called `_Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC` which is incorrect. Now it has been fixed. (cherry picked from commit ab05beb)
1 parent 430ccbc commit fdac362
Copy full SHA for fdac362

File tree

Expand file treeCollapse file tree

3 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-0
lines changed

‎Include/cpython/pystats.h

Copy file name to clipboardExpand all lines: Include/cpython/pystats.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
//
1919
// Define _PY_INTERPRETER macro to increment interpreter_increfs and
2020
// interpreter_decrefs. Otherwise, increment increfs and decrefs.
21+
//
22+
// The number of incref operations counted by `incref` and
23+
// `interpreter_incref` is the number of increment operations, which is
24+
// not equal to the total of all reference counts. A single increment
25+
// operation may increase the reference count of an object by more than
26+
// one. For example, see `_Py_RefcntAdd`.
2127

2228
#ifndef Py_CPYTHON_PYSTATS_H
2329
# error "this header file must not be included directly"

‎Include/internal/pycore_object.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_object.h
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
155155
_Py_atomic_add_ssize(&op->ob_ref_shared, (n << _Py_REF_SHARED_SHIFT));
156156
}
157157
#endif
158+
// Although the ref count was increased by `n` (which may be greater than 1)
159+
// it is only a single increment (i.e. addition) operation, so only 1 refcnt
160+
// increment operation is counted.
161+
_Py_INCREF_STAT_INC();
158162
}
159163
#define _Py_RefcntAdd(op, n) _Py_RefcntAdd(_PyObject_CAST(op), n)
160164

+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix statistics for increments of object reference counts (in particular, when
2+
a reference count was increased by more than 1 in a single operation).

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.