Skip to content

_Py_RefcntAdd doesn't increment ref count stats #127599

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

Closed
EdNutting opened this issue Dec 4, 2024 · 3 comments · Fixed by #127717
Closed

_Py_RefcntAdd doesn't increment ref count stats #127599

EdNutting opened this issue Dec 4, 2024 · 3 comments · Fixed by #127717
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@EdNutting
Copy link
Contributor

EdNutting commented Dec 4, 2024

Bug report

Bug description:

Hi,

I am unsure if this intentional or not so apologies if this turns out not to be a bug.

The code for _Py_RefcntAdd does not include _Py_INCREF_STAT_INC. This appears to mean the statistics do not track these additions to the reference count, which are increments (although not increments by 1, they are increasing the ref count in a single operation).

static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)

I believe this may be an oversight because this stat should be tracked, and also because the corresponding decrement ref count code does call _Py_DECREF_STAT_INC (e.g.

_Py_DECREF_STAT_INC();
)

I have checked the callers of _Py_RefcntAdd (in listobject.c and tupleobject.c) and they do not separately perform the stats tracking.

Is this an issue or is there a reason this ref count increment is excluded?

Thanks,
Ed

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux, macOS

Linked PRs

@EdNutting EdNutting added the type-bug An unexpected behavior, bug, or error label Dec 4, 2024
@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Dec 4, 2024
@ZeroIntensity
Copy link
Member

Looks like a bug. We're missing _Py_INCREF_IMMORTAL_STAT_INC for immortal objects as well.

@EdNutting
Copy link
Contributor Author

Thank you for such a quick reply! I'll try to clone CPython separately to create a PR to fix these over the next few days.

Eclips4 pushed a commit that referenced this issue Dec 15, 2024
…_INCREF_IMMORTAL_STAT_INC (#127717)

Previously, `_Py_RefcntAdd` hasn't called 
`_Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC` which is incorrect. 

Now it has been fixed.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 15, 2024
…NC/_Py_INCREF_IMMORTAL_STAT_INC (pythonGH-127717)

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)

Co-authored-by: Ed Nutting <[email protected]>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 8, 2025
…NC/_Py_INCREF_IMMORTAL_STAT_INC (python#127717)

Previously, `_Py_RefcntAdd` hasn't called 
`_Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC` which is incorrect. 

Now it has been fixed.
EdNutting added a commit to EdNutting/cpython that referenced this issue Jan 10, 2025
…_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC (pythonGH-127717)

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)

Co-authored-by: Ed Nutting <[email protected]>
EdNutting added a commit to EdNutting/cpython that referenced this issue Jan 10, 2025
…_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC (pythonGH-127717)

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)

Co-authored-by: Ed Nutting <[email protected]>
EdNutting added a commit to EdNutting/cpython that referenced this issue Jan 10, 2025
…_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC (pythonGH-127717)

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)

Co-authored-by: Ed Nutting <[email protected]>
Eclips4 pushed a commit that referenced this issue Jan 18, 2025
…INC/_Py_INCREF_IMMORTAL_STAT_INC (GH-127717) (#128712)

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)
Eclips4 pushed a commit that referenced this issue Jan 18, 2025
…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)
@Eclips4
Copy link
Member

Eclips4 commented Jan 18, 2025

Thank you @EdNutting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
3 participants