Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix bug -- if sym->typ is NULL, don't cry bottom
  • Loading branch information
gvanrossum committed Feb 28, 2024
commit b0509ce79405748556b78946a4c81f235dd91c03
2 changes: 1 addition & 1 deletion Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ _Py_uop_sym_set_const(_Py_UopsSymbol *sym, PyObject *const_val)
return;
}
PyTypeObject *typ = Py_TYPE(const_val);
if (sym->typ != typ) {
if (sym->typ != NULL && sym->typ != typ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified to

Suggested change
if (sym->typ != NULL && sym->typ != typ) {
if (sym->typ != typ) {

as Py_TYPE(const_val) cannot be NULL.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see this was a bug I introduced. Sorry.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out this "fix" was wrong -- we're not checking whether typ is NULL, we're checking whether sym->typ isn't NULL. If it's NULL, setting the constant should be allowed. Running the tests with PYTHONUOPSOPTIMIZE=1 revealed this. :-)

sym_set_bottom(sym);
return;
}
Expand Down