| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix SystemError / segmentation fault in iter ``__reduce__`` when internal access of ``builtins.__dict__`` keys mutates the iter object. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -3444,18 +3444,22 @@ listiter_reduce_general(void *_it, int forward) | |
| { | ||
| PyObject *list; | ||
|
|
||
| /* _PyEval_GetBuiltin can invoke arbitrary code, | ||
| * call must be before access of iterator pointers. | ||
| * see issue #101765 */ | ||
|
|
||
| /* the objects are not the same, index is of different types! */ | ||
| if (forward) { | ||
| PyObject *iter = _PyEval_GetBuiltin(&_Py_ID(iter)); | ||
| _PyListIterObject *it = (_PyListIterObject *)_it; | ||
| if (it->it_seq) { | ||
| return Py_BuildValue("N(O)n", _PyEval_GetBuiltin(&_Py_ID(iter)), | ||
| it->it_seq, it->it_index); | ||
| return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index); | ||
| } | ||
| } else { | ||
| PyObject *reversed = _PyEval_GetBuiltin(&_Py_ID(reversed)); | ||
|
Comment thread
ionite34 marked this conversation as resolved.
|
||
| listreviterobject *it = (listreviterobject *)_it; | ||
| if (it->it_seq) { | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIf it_seq is NULL then reversed is leaked here, _PyEval_GetBuiltin returns a strong reference.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGood point, but doesn't that mean the old code also leaked references? I'll prepare a PR to fix this now.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOh wait, the N code to Py_BuildValue steals a reference, so the previous code was right in terms of refcounting.
Sorry, something went wrong.
All reactions
|
||
| return Py_BuildValue("N(O)n", _PyEval_GetBuiltin(&_Py_ID(reversed)), | ||
| it->it_seq, it->it_index); | ||
| return Py_BuildValue("N(O)n", reversed, it->it_seq, it->it_index); | ||
| } | ||
| } | ||
| /* empty iterator, create an empty list */ | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy do we need to del first? We set the correct key on the next line anyway.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt's to not invoke the __eq__ from our test CustomStr, since the string key will collide with the same hash. I added some more comments regarding this in c67b11a
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh, right! This thing is breaking my assumptions about how dicts should behave :)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.