Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-117139: Fix a few wrong steals in bytecodes.c#121127
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Fidget-Spinner commented Jun 28, 2024 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
Uh oh!
There was an error while loading. Please reload this page.
| } | ||
| else{ | ||
| err=PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectSteal(v)); | ||
| err=PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectBorrow(v)); |
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.
PyObject_SetItem and the entire family actually takes borrowed references to the container and item. So this steal is wrong, it should be borrow.
This was caught when the PyStackRef_CLOSE(v) below tried to close an already invalid stackref (it was made invalid by the steal).
| inst(SET_ADD, (set, unused[oparg-1], v--set, unused[oparg-1])){ | ||
| interr=PySet_Add(PyStackRef_AsPyObjectBorrow(set), | ||
| PyStackRef_AsPyObjectSteal(v)); | ||
| PyStackRef_AsPyObjectBorrow(v)); |
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.
Same for PySet_Add
| PyObject*name=GETITEM(FRAME_CO_NAMES, oparg); | ||
| interr=PyObject_SetAttr(PyStackRef_AsPyObjectBorrow(owner), | ||
| name, PyStackRef_AsPyObjectSteal(v)); | ||
| name, PyStackRef_AsPyObjectBorrow(v)); |
Fidget-SpinnerJun 28, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
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.
PyObject_SetAttr actually takes borrowed refs too, so this shouldn't be stolen. This was caught when the DECREF_INPUTS tried to close an already stolen stackref.
bedevere-bot commented Jun 28, 2024
|
Fidget-Spinner commented Jun 28, 2024
It looks unrelated and more like a buildbot problem. |
Fix a few wrong steals in bytecodes.c
Fix a few wrong steals in bytecodes.c
Fix a few wrong steals in bytecodes.c
I actually caught these using a tool I built following the stackref semantics here https://github.com/faster-cpython/ideas/blob/kenjin/stackref-semantics/3.14/stackref_semantics.md.
I'll send the PR for the tool in a separate PR.
These bugs were quite hard to notice, I will explain each one in comments below.