-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,7 @@ dummy_func( | |
} | ||
|
||
replicate(8) pure inst(LOAD_FAST, (-- value)) { | ||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL); | ||
assert(!PyStackRef_IsNull(GETLOCAL(oparg))); | ||
value = PyStackRef_DUP(GETLOCAL(oparg)); | ||
} | ||
|
||
|
@@ -673,7 +673,7 @@ dummy_func( | |
err = 1; | ||
} | ||
else { | ||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectSteal(v)); | ||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectBorrow(v)); | ||
Py_DECREF(slice); | ||
} | ||
PyStackRef_CLOSE(v); | ||
|
@@ -789,7 +789,7 @@ dummy_func( | |
|
||
inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) { | ||
int err = PySet_Add(PyStackRef_AsPyObjectBorrow(set), | ||
PyStackRef_AsPyObjectSteal(v)); | ||
PyStackRef_AsPyObjectBorrow(v)); | ||
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. Same for PySet_Add |
||
DECREF_INPUTS(); | ||
ERROR_IF(err, error); | ||
} | ||
|
@@ -813,7 +813,7 @@ dummy_func( | |
|
||
op(_STORE_SUBSCR, (v, container, sub -- )) { | ||
/* container[sub] = v */ | ||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectSteal(sub), PyStackRef_AsPyObjectSteal(v)); | ||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectBorrow(sub), PyStackRef_AsPyObjectBorrow(v)); | ||
DECREF_INPUTS(); | ||
ERROR_IF(err, error); | ||
} | ||
|
@@ -1235,7 +1235,7 @@ dummy_func( | |
inst(POP_EXCEPT, (exc_value -- )) { | ||
_PyErr_StackItem *exc_info = tstate->exc_info; | ||
Py_XSETREF(exc_info->exc_value, | ||
PyStackRef_AsPyObjectBorrow(exc_value) == Py_None | ||
PyStackRef_Is(exc_value, PyStackRef_None) | ||
? NULL : PyStackRef_AsPyObjectSteal(exc_value)); | ||
} | ||
|
||
|
@@ -1330,9 +1330,9 @@ dummy_func( | |
ERROR_IF(true, error); | ||
} | ||
if (PyDict_CheckExact(ns)) | ||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v)); | ||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v)); | ||
else | ||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v)); | ||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v)); | ||
DECREF_INPUTS(); | ||
ERROR_IF(err, error); | ||
} | ||
|
@@ -1450,7 +1450,7 @@ dummy_func( | |
op(_STORE_ATTR, (v, owner --)) { | ||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); | ||
int err = PyObject_SetAttr(PyStackRef_AsPyObjectBorrow(owner), | ||
name, PyStackRef_AsPyObjectSteal(v)); | ||
name, PyStackRef_AsPyObjectBorrow(v)); | ||
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. PyObject_SetAttr actually takes borrowed refs too, so this shouldn't be stolen. This was caught when the |
||
DECREF_INPUTS(); | ||
ERROR_IF(err, error); | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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).