-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-38152: Fix refleak in the finalizer of AST type < 8000 span class="f1-light color-fg-muted">#16127
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
f9c9bf2
to
7d84e19
Compare
Previously this was failing, and it's passing now:
I also ran all the modules that were referred to by the issue and all of them are passing now:
|
cc @matrixise |
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.
LGTM with requested change.
I think a little bit of documentation change would be helpful here as well. With heap-allocated types like this, if there is a custom tp_dealloc
then the user must remember to DECREF the type object.
I noticed when you introduced INCREF for heap types, you added a whatsnew entry. I think it would be advisable to add this information to https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_dealloc as well, just so there's somewhere to point to about this behavior.
I would even suggest add a comment here explaining the reason for the DECREF on the type.
@@ -638,9 +638,13 @@ def visitModule(self, mod): | |||
ast_dealloc(AST_object *self) |
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.
While you're in here, could you fix the typo introduced here:
Lines 1236 to 1237 in d057b89
{Py_tp_free, PyType_GenericNew}, | |
{Py_tp_free, PyObject_GC_Del}, |
(Py_tp_free
is duplicated, once incorrectly set to PyType_GenericNew
)
@DinoV: Please replace |
@ammaraskar makes sense. I'll send a PR updating the docs |
…H-16248) As mentioned in the bpo ticket, this mistake came up on two reviews: - #16127 (review) - #16071 (review) Would be nice to have it documented in a more permanent place than 3.8's whatsnew entry. https://bugs.python.org/issue38206 Automerge-Triggered-By: @encukou
…ythonGH-16248) As mentioned in the bpo ticket, this mistake came up on two reviews: - python#16127 (review) - python#16071 (review) Would be nice to have it documented in a more permanent place than 3.8's whatsnew entry. https://bugs.python.org/issue38206 Automerge-Triggered-By: @encukou
The
AST_object
was leaking its reference to theAST
type. This change properly decreases the reference to the type at deallocation time. Also, this modifiestp_free
to usePyType_GetSlot
to makePyTypeObject
opaque.https://bugs.python.org/issue38152