Skip to content

GH-127705: Handle trace refs in specialized decref #131198

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

Merged

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Mar 13, 2025

Adds a couple of _Py_ForgetReferences that were overlooked.

@markshannon
Copy link
Member Author

!buildbot TraceRef

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @markshannon for commit b5eb234 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131198%2Fmerge

The command will test the builders whose names match following regular expression: TraceRef

The builders matched are:

  • AMD64 Arch Linux TraceRefs PR

Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be exposing Py_DECREF_MORTAL and Py_DECREF_MORTAL_SPECIALIZED to extensions when they include Python.h. It seems to me like they belong in pycore_object.h or some other internal-only header.

@@ -420,6 +420,9 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
_Py_DECREF_DecRefTotal();
}
if (--op->ob_refcnt == 0) {
#ifdef Py_TRACE_REFS
_Py_ForgetReference(op);
#endif
destruct(op);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a _PyReftracerTrack(op, PyRefTracer_DESTROY);

@markshannon
Copy link
Member Author

I don't think we should be exposing Py_DECREF_MORTAL and Py_DECREF_MORTAL_SPECIALIZED to extensions when they include Python.h. It seems to me like they belong in pycore_object.h or some other internal-only header.

I agree, but it is infeasible now due to cyclic includes.
I'll do that and add the _PyReftracerTrack(op, PyRefTracer_DESTROY); once I've sorted out #131238

@encukou
Copy link
Member

encukou commented Mar 14, 2025

Merging as is, so we don't release with sys.getobjects segfaulting.

@encukou encukou merged commit 67af96c into python:main Mar 14, 2025
46 checks passed
@vstinner
Copy link
Member

Can you please rename Py_DECREF_MORTAL_SPECIALIZED() to _Py_DECREF_MORTAL_SPECIALIZED() in the public C API?

plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
…1198)

This is missing `_PyReftracerTrack` calls, see pythongh-131238.
Merging as-is for the 3.14.0a6 release.
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
…1198)

This is missing `_PyReftracerTrack` calls, see pythongh-131238.
Merging as-is for the 3.14.0a6 release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants