Skip to content

Commit b407312

Browse files
authored
GH-94893: Ignore caches when adding LOAD_FAST_CHECKs (GH-94894)
1 parent 067f0da commit b407312

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an issue where frame object manipulations could corrupt inline bytecode
2+
caches.

Objects/frameobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ add_load_fast_null_checks(PyCodeObject *co)
603603
int changed = 0;
604604
_Py_CODEUNIT *instructions = _PyCode_CODE(co);
605605
for (Py_ssize_t i = 0; i < Py_SIZE(co); i++) {
606-
switch (_Py_OPCODE(instructions[i])) {
606+
int opcode = _Py_OPCODE(instructions[i]);
607+
switch (opcode) {
607608
case LOAD_FAST:
608609
case LOAD_FAST__LOAD_FAST:
609610
case LOAD_FAST__LOAD_CONST:
@@ -619,6 +620,7 @@ add_load_fast_null_checks(PyCodeObject *co)
619620
_Py_SET_OPCODE(instructions[i], STORE_FAST);
620621
break;
621622
}
623+
i += _PyOpcode_Caches[_PyOpcode_Deopt[opcode]];
622624
}
623625
if (changed) {
624626
// invalidate cached co_code object

0 commit comments

Comments
 (0)