-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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-101765: Fix refcount issues in list and unicode pickling #102265
Conversation
🤖 New build scheduled with the buildbot fleet by @JelleZijlstra for commit b8ad59e 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
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
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry, @JelleZijlstra, I could not cleanly backport this to |
Sorry @JelleZijlstra, I had trouble checking out the |
Working on the backports |
GH-102268 is a backport of this pull request to the 3.11 branch. |
…ing (pythonGH-102265) Followup from pythonGH-101769.. (cherry picked from commit d71edbd) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-102269 is a backport of this pull request to the 3.10 branch. |
…ing (pythonGH-102265) Followup from pythonGH-101769.. (cherry picked from commit d71edbd) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@@ -14794,8 +14794,10 @@ unicodeiter_reduce(unicodeiterobject *it, PyObject *Py_UNUSED(ignored)) | |||
return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index); | |||
} else { | |||
PyObject *u = unicode_new_empty(); | |||
if (u == NULL) | |||
if (u == NULL) { | |||
Py_DECREF(iter); |
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.
Shouldn't this be Py_XDECREF
? There is no null check above for iter.
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.
Good point. But shouldn’t it be a null check and return above, if iter is null I think it would crash in the BuildValue before we even get here.
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.
Py_BuildValue
deals with NULL internally; if one of the args is NULL it itself returns NULL, propagating the exception. So changing to XDECREF here should be enough.
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.
Followup from #101769.
__reduce__
can segfault if accessing__builtins__.__dict__['iter']
mutates the iter object #101765