-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-118605: Fix reference leak in FrameLocalsProxy #118607
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
gh-118605: Fix reference leak in FrameLocalsProxy #118607
Conversation
@@ -306,7 +308,10 @@ framelocalsproxy_visit(PyObject *self, visitproc visit, void *arg) | |||
static PyObject * | |||
framelocalsproxy_iter(PyObject *self) | |||
{ | |||
return PyObject_GetIter(framelocalsproxy_keys(self, NULL)); | |||
PyObject* keys = framelocalsproxy_keys(self, NULL); |
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.
Probably should error-check this too, and the PyList_Append in that function could fail so should clean up and return NULL.
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.
Also, there is a lack of error checking in some new "frameobject.c" functions. I will create a separate issue for this.
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.
I fixed the framelocalsproxy_keys
related checks. We can address the others in a seperate PR?
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.
Okay, we can merge this now and for the rest the separate PR.
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.
Whoops, there's another error check on line 243 (PyList_New(0)
). Sorry for the premature approval.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Right, I actually caught that while I was working on the PR to add proper checks, but I'm happy to make it in this PR. |
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.
I would have put that immediately after the PyObject *names = ...
line, but this is fine. Good luck with the rest!
I put it after to make the declarations stick together because the other two declarations is quick and without any memory allocation. I also understand why people would put the check immediately after the declaration, but in this specific case I'm leaning slightly more towards the current way. |
Doing it immediately has some advantages for people used to reading through this code base. But since I already set up auto-commit, let's keep it as is. |
I can polish it up in the next PR that does a bunch of fixes everywhere. |
Also add some error checks.
There are a couple of reference leaks in the implementation of PEP 667. Fix those and hopefully that's all.
test_bdb
leaks references #118605