gh-135608: Add a null check for attribute promotion to fix a JIT crash (GH-135613)

Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
This commit is contained in:
Ken Jin 2025-06-20 14:33:35 +08:00 committed by GitHub
parent c8c13f8036
commit b53b0c14da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 2 deletions

View file

@ -103,6 +103,10 @@ convert_global_to_const(_PyUOpInstruction *inst, PyObject *obj, bool pop)
if ((int)index >= dict->ma_keys->dk_nentries) {
return NULL;
}
PyDictKeysObject *keys = dict->ma_keys;
if (keys->dk_version != inst->operand0) {
return NULL;
}
PyObject *res = entries[index].me_value;
if (res == NULL) {
return NULL;

View file

@ -591,7 +591,13 @@ dummy_func(void) {
PyDict_Watch(GLOBALS_WATCHER_ID, dict);
_Py_BloomFilter_Add(dependencies, dict);
PyObject *res = convert_global_to_const(this_instr, dict, true);
attr = sym_new_const(ctx, res);
if (res == NULL) {
attr = sym_new_not_null(ctx);
}
else {
attr = sym_new_const(ctx, res);
}
}
}
}

View file

@ -1266,7 +1266,12 @@
PyDict_Watch(GLOBALS_WATCHER_ID, dict);
_Py_BloomFilter_Add(dependencies, dict);
PyObject *res = convert_global_to_const(this_instr, dict, true);
attr = sym_new_const(ctx, res);
if (res == NULL) {
attr = sym_new_not_null(ctx);
}
else {
attr = sym_new_const(ctx, res);
}
}
}
}