-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_DICT #142712
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
base: main
Are you sure you want to change the base?
Conversation
Python/bytecodes.c
Outdated
| } | ||
| INPUTS_DEAD(); | ||
| st = dict_st; | ||
| sb = sub; |
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.
Reference to sub is already stolen by _PyDict_SetItem_Take2. So you can't pass this down.
Python/bytecodes.c
Outdated
| PyStackRef_CLOSE(dict_st); | ||
| ERROR_IF(err); | ||
| if (err) { | ||
| ERROR_NO_POP(); |
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.
We can't do this here. The problem is that _PyDict_SetItem_Take2 has already stolen the references to sub and value. This means when we jump to error, we decref sub and value again, causing a double decref.
The fix might be to do
if (err) {
PyStackRef_CLOSE(dict_st);
ERROR_IF(1);
}
|
@Fidget-Spinner Done :) Thanks for the guide. |
| } | ||
|
|
||
| op(_STORE_SUBSCR_DICT, (value, dict_st, sub -- st)) { | ||
| (void)value; |
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.
Can you please add a (void)sub here as well? So that we don't get compiler warnings.
Uh oh!
There was an error while loading. Please reload this page.