-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for PyType_FromSpec types (reverts GH-19414) #20264
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
Conversation
Would it be possible to prepare a PR to explain how to fix the issue? Also, is there someone interested to fix all C extensions of CPython stdlib for this issue? |
I can do both if we end agreeing that that is the way to go |
…r PyType_FromSpec types (pythonGH-19414)" This reverts commit 0169d30.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the type->tp_traverse == (traverseproc)foo_traverse
checks (and the but not for subclasses remarks) necessary? AFAIK, the check will always be true for calls that Python itself makes.
It might necessary to do the check in the reproducer I posted on the bug, but only because that module's own call to base_traverse
.
But it might be that I'm misunderstanding the situation.
Never mind; I'm wrong about that. Sorry. |
I'll try going with the idea that each instance of a heap type must Py_VISIT its class, and if it calls another heap type's |
@encukou Could you elaborate a bit more the idea you are proposing? I would love to eliminate the checks for subclasses bit sadly the subclass traverse is already visiting the type itself when traversing the hierarchy. |
If the base is a heap type, the responsibility to visit Py_TYPE(self) is delegated to the base's tp_traverse.
The Python 3.8 behavior is buggy. If a custom I don't like the "Ensure that all custom So, I'd like to acknowledge that Python 3.8 has the bug, set up a cleaner rule on what I'll make a PR out of that shortly. |
See #20433 |
Gotcha! I very much agree with your analysis. Do you plant to backport this? Feel free to push to this PR of you wish |
I don't think it's worth it to backport, unfortunately. Not visiting IMO, it is more important to be consistent across 3.8.x than to avoid the leak. If backported to 3.8.4, we get an unfortunate case:
|
@pablogsal: Status check is done, and it's a success ✅ . |
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
GH-20490 is a backport of this pull request to the 3.9 branch. |
Correction: I do want to backport to 3.9. That's probably what you were asking about, right? |
Heap types now always visit the type in tp_traverse. See added docs for details.
This reverts commit 0169d30.
https://bugs.python.org/issue40217
Automerge-Triggered-By: @encukou