Commit 4a63c4d
committed
W22: fix bounds-check units mismatch (BCOffset bytes vs BCIndex count)
v2 28178f4 used 'BCOffset next_off = bci.nextInstrOffset(); if
(next_off < bc_block.size())'. nextInstrOffset() returns BCOffset
(bytes — see Python/jit/bytecode_offsets.h:115); bc_block.size()
returns Py_ssize_t in instruction-count units (Python/jit/bytecode.cpp:
122 returns end_idx_ - start_idx_, both BCIndex).
The integral comparison overload of BCOffset (bytecode_offsets.h:130)
compares the byte value against the instruction count, so for any
function past the first ~1 instruction the check evaluates FALSE and
the deopt-throw is bypassed. Net effect: yield-from re-enters the JIT
and W22 SIGABRT returns (caught by testkeeper 14:40:22Z STRICT VERIFY).
Fix: assign nextInstrOffset() to BCIndex instead of BCOffset. The
implicit BCIndex(BCOffset) constructor at bytecode_offsets.h:176
divides by sizeof(_Py_CODEUNIT)=2, matching the units of bc_block.
size(). This is the exact pattern used at builder.cpp:1143 (the
existing 3.11+ bounds-check precedent).
Catch: testkeeper 14:40:22Z STRICT VERIFY DOUBLE FAIL — Criterion 1
yield-from auto-compile re-crashed with original W22 SIGABRT 134
(register v11 not live) at iter 999, await also still crashed at
iter 1000 (same root cause: deopt-throw bypassed → YIELD_VALUE
compiles → end-of-bytecode SIGSEGV in compiled path).
Lesson (memory amendment): dis.dis fixture verification confirms
oparg-mapping but does NOT confirm the C++ deopt-throw actually fires;
runtime test (compile + execute + verify is_jit_compiled=False) is
required for pattern-deopt commits.1 parent 28178f4 commit 4a63c4d
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4951 | 4951 | | |
4952 | 4952 | | |
4953 | 4953 | | |
4954 | | - | |
4955 | | - | |
| 4954 | + | |
| 4955 | + | |
| 4956 | + | |
| 4957 | + | |
| 4958 | + | |
| 4959 | + | |
| 4960 | + | |
| 4961 | + | |
| 4962 | + | |
4956 | 4963 | | |
4957 | 4964 | | |
4958 | 4965 | | |
| |||
0 commit comments