Skip to content
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

bpo-44881: Integrate GC untrack into trashcan begin. #27718

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nascheme
Copy link
Member

@nascheme nascheme commented Aug 10, 2021

For subtle reasons, PyObject_GC_UnTrack() function must be called before
Py_TRASHCAN_BEGIN(). There have been a number of bugs over the years
related to not doing this particular dance just right. Integrating
the PyObject_GC_UnTrack() call makes it harder to do things incorrectly.
That avoids some hard to find bugs (e.g. only triggered when object
nesting gets deep enough).

Extensions that still call PyObject_GC_UnTrack() explictly will
work correctly but the call is unneeded after this change. It would
still be needed for the extension to work correctly with older versions
of Python.

https://bugs.python.org/issue44881

For subtle reasons, PyObject_GC_UnTrack() function must be called before
Py_TRASHCAN_BEGIN().  There have been a number of bugs over the years
related to not doing this particular dance just right.  Integrating
the PyObject_GC_UnTrack() call makes it harder to do things incorrectly.
That avoids some hard to find bugs (e.g. only triggered when object
nesting gets deep enough).

Extensions that still call PyObject_GC_UnTrack() explictly will still
work correctly but the call is unneeded after this change.  It would
still be needed for the extension to work correctly with older versions
of Python.
@pablogsal
Copy link
Member

Let's land #27678 first to include that change in this PR

@nascheme
Copy link
Member Author

Just to be clear, I don't consider this PR a bugfix and it would not be appropriate to include in 3.10.

@pablogsal
Copy link
Member

Just to be clear, I don't consider this PR a bugfix and it would not be appropriate to include in 3.10.

Yep, we are on the same page :)

It seems slightly cleaner to have the BEGIN/END macros at the start and
end of the dealloc function body.
@ambv
Copy link
Contributor

ambv commented Aug 16, 2021

We won't be merging this as of yet because an alternative solution is evaluated in GH-27738. I added the assert Victor wanted so that the benchmarks are fairer between the two approaches.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Sep 16, 2021
@rhettinger rhettinger removed their request for review May 3, 2022 06:19
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 11, 2022
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.

7 participants