Skip to content

Commit

Permalink
Double check that keys are still valid
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Nov 8, 2024
1 parent 8f6239d commit 49ec70a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,11 @@ dummy_func(
#if Py_GIL_DISABLED
int increfed = _Py_TryIncrefCompare(&entries[index].me_value, res_o);
DEOPT_IF(!increfed);
PyDictObject *dict = (PyDictObject*) GLOBALS();
if (globals_keys != _Py_atomic_load_ptr_acquire(&dict->ma_keys)) {
Py_DECREF(res_o);
DEOPT_IF(true);
}
#else
Py_INCREF(res_o);
#endif
Expand All @@ -1650,6 +1655,11 @@ dummy_func(
#if Py_GIL_DISABLED
int increfed = _Py_TryIncrefCompare(&entries[index].me_value, res_o);
DEOPT_IF(!increfed);
PyDictObject *dict = (PyDictObject*) BUILTINS();
if (builtins_keys != _Py_atomic_load_ptr_acquire(&dict->ma_keys)) {
Py_DECREF(res_o);
DEOPT_IF(true);
}
#else
Py_INCREF(res_o);
#endif
Expand Down
16 changes: 16 additions & 0 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Tools/cases_generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
"_Py_NewRef",
"_Py_SINGLETON",
"_Py_STR",
"_Py_atomic_load_ptr_acquire",
"_Py_atomic_load_uintptr_relaxed",
"_Py_set_eval_breaker_bit",
"advance_backoff_counter",
Expand Down

0 comments on commit 49ec70a

Please sign in to comment.