gh-145122: Add _GUARD_NOS_ANY_DICT to prevent STORE_SUBSCR_DICT on frozendict (gh-145039)

This commit is contained in:
Donghee Na 2026-02-25 00:48:45 +09:00 committed by GitHub
parent 4c95ad8e49
commit 0f759f1171
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 1244 additions and 1079 deletions

View file

@ -1348,13 +1348,6 @@ dummy_func(void) {
sym_set_type(nos, &PyTuple_Type);
}
op(_GUARD_TOS_DICT, (tos -- tos)) {
if (sym_matches_type(tos, &PyDict_Type)) {
ADD_OP(_NOP, 0, 0);
}
sym_set_type(tos, &PyDict_Type);
}
op(_GUARD_NOS_DICT, (nos, unused -- nos, unused)) {
if (sym_matches_type(nos, &PyDict_Type)) {
ADD_OP(_NOP, 0, 0);
@ -1362,6 +1355,22 @@ dummy_func(void) {
sym_set_type(nos, &PyDict_Type);
}
op(_GUARD_NOS_ANY_DICT, (nos, unused -- nos, unused)) {
PyTypeObject *tp = sym_get_type(nos);
if (tp == &PyDict_Type || tp == &PyFrozenDict_Type) {
ADD_OP(_NOP, 0, 0);
sym_set_type(nos, tp);
}
}
op(_GUARD_TOS_ANY_DICT, (tos -- tos)) {
PyTypeObject *tp = sym_get_type(tos);
if (tp == &PyDict_Type || tp == &PyFrozenDict_Type) {
ADD_OP(_NOP, 0, 0);
sym_set_type(tos, tp);
}
}
op(_GUARD_TOS_ANY_SET, (tos -- tos)) {
if (sym_matches_type(tos, &PySet_Type) ||
sym_matches_type(tos, &PyFrozenSet_Type))