Commit ebec018
committed
W-I3-RUNTIME-ASSERT (IV)+(III): BasicBlock::id immutability gate + sentinel
Per docs/w-i3-runtime-assert-spec.md (theologian 21:57:02Z, supervisor
22:10:02Z, librarian 22:05:19Z framework guidance). Closes pythia
python#128 / python#131 python#1 named risk: I3 invariant (BasicBlock::id is allocation-
monotonic AND never mutated post-allocation) is grep-only, not
runtime-asserted.
Phase B B-gamma's PhxBcBlockArray (Tier 8 SECOND-PILOT, push 40
4145fe3) indexes by BasicBlock::id. A future HIR pass that
renumbers ids (SSA-destruction-style cache-locality renumbering,
peephole block-splitter, speculative-inlining clone) would silently
corrupt the dense-array lookup; I2 read-site check catches out-of-
range, NOT stale-mapping-correct-range.
(IV) CI grep gate — scripts/check_i3_invariant.sh + Step 1h wire:
- Detects "->id =", ".id =", set_id(/setId( patterns in Python/jit/hir/.
- Allow-list excludes legitimate non-BasicBlock matches:
* HirLoadAttrSpecial::id (void* attribute identifier, different
class)
* next_register_id_, cache_id_ (different fields, trailing
underscore)
* test_*.c, hir_instr_c_verify.cpp (read-path testing, per W44
ALLOW_LIST precedent)
- Falsification-tested: synthetic patch adding "block->id = 42;"
to Python/jit/hir/synth_i3_violation.cpp triggers GATE FAIL EXIT=1
under --strict; removing the patch returns to GATE PASS EXIT=0.
- Wired as Step 1h in scripts/gate_phoenix.sh per librarian 22:05:19Z
framework guidance, mirroring Steps 1e/1g delegation shape (capture
OUTPUT, tee to RESULTS_FILE, GATE_PASS=0 + FAILURES on nonzero).
(III) JIT_DCHECK pydebug sentinel — PhxBcBlockEntry.sentinel_id:
- Adds int sentinel_id field under #ifdef Py_DEBUG to PhxBcBlockEntry
(zero release-build cost; pydebug entry size 8 -> 12 bytes).
- Insert sets sentinel_id = block_id at insert time.
- Lookup verifies sentinel_id == block_id via JIT_DCHECK_C; mismatch
fires JIT_CHECK_C abort with diagnostic indicating either a
post-allocation id mutation OR inserter/reader index disagreement.
- catches the (IV) miss-class: id mutation via member function /
indirect pointer write that grep doesn't pattern-match.
Combined cost: zero release runtime; ~45min implementation. (I)
sentinel-always and (II) generation-counter REJECTED per spec §3 as
reverse perf trade without strong evidence the always-on detection
is required vs (IV)+(III) catching at commit + pydebug.
Build implications: Py_DEBUG-conditional layout change to
PhxBcBlockEntry. Per JIT Header Change Protocol (CLAUDE.md), requires
full distclean rebuild; testkeeper to verify both release (sentinel
field absent, struct == 8 bytes) and pydebug (sentinel field present,
struct == 12 bytes, JIT_DCHECK_C does not fire on normal workload).
ARM64 verification via standard ARM64 retroactive-debt path once
devgpu004 SSH-2FA infra restored.
Auth: theologian spec 21:57:02Z + supervisor CONCUR 21:57:20Z +
22:10:02Z; librarian framework guidance 22:05:19Z (Step 1h shape
mirroring 1e/1g, scripts/check_i3_invariant.sh --strict).1 parent 85ed449 commit ebec018
3 files changed
Lines changed: 192 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
237 | 247 | | |
238 | 248 | | |
239 | 249 | | |
| |||
287 | 297 | | |
288 | 298 | | |
289 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
290 | 303 | | |
291 | 304 | | |
292 | 305 | | |
293 | 306 | | |
294 | 307 | | |
295 | 308 | | |
296 | 309 | | |
297 | | - | |
| 310 | + | |
| 311 | + | |
298 | 312 | | |
299 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
300 | 322 | | |
301 | 323 | | |
302 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
222 | 240 | | |
223 | 241 | | |
224 | 242 | | |
| |||
0 commit comments