You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stage1 panics "index out of bounds" in math_fn_arity (MathBuiltins.w:82) checking sin() under a raylib c_import; the release compiler of the same sources does not #1991
Found verifying #1900 on branch wave-build (built from 44a960fe; reproduced as well with the stage1 of 7ffceab6, so it predates that branch's runner changes).
Repro: the spiral program (use c_import("raylib.h"), sin(t * 1.4 + p * 6) inside a for i in 0..140 loop) in a project with c.raylib = "6.0" installed, built by a stage1: WITH=<stage1> <stage1> build.
Actual:panic: index out of bounds, rc 134. lldb:
frame #1: math_fn_arity(id=<unavailable>) at MathBuiltins.w:82:16
frame #2: Sema.check_intrinsic_call(fn_sym=914, node=578974, arg_count=1) at SemaCheck.w:29546:44
frame #3: Sema.check_call(node=578974) at SemaCheck.w:22774:74
frame #5: Sema.check_binary(node=578976) at SemaCheck.w:11707:57
frame #9: Sema.check_let_binding(node=578978) at SemaCheck.w:12817:129
frame #12: Sema.check_for(node=579018) at SemaCheck.w:15112:63
Release compiler of the same sources (out/release/bin/with, stage2's image): no panic; it reports the program's first error (i / 140.0, §4.2.6) and exits 1.
Expected: stage1 and the release agree (no panic; a diagnostic). A stage1-only divergence over identical sources points at the seed's compilation of stage1 (MathBuiltins / check_intrinsic_call) rather than at the source; the exact line is not yet established.
A trivial project shows the designed D30 refusal for a stage1 copied away from its tree, so this is not the missing-runtime case.
Does not reproduce on main c884c1c: a stage1 built by the pinned seed and one built by the new darwin seed (nightly-20261003-local-1-c884c1c2a17c) both build examples/spiral to the program's real §4.2.6 error (i / 140.0), no panic, matching the release compiler. Closed per Eric (2026-10-03); reopen with a repro if it returns.
Reopened: the stage1-only 'index out of bounds' class reproduces again (2026-10-03, during #2043 work) on behav_d70_import_namespaces, math_builtins, behav_1874_simd_c_abi_darwin and behav_c_import_inline_math_builtin_call: panics under stage1 only, the same on the previous commit's stage1, passing on the release binary. Being fixed now.
Root cause, at the instruction level: the old pinned seed's lowering (nightly-20260929-local-2-c95ae12d9f64 = v0.15.3.0-g8f84428e5, digest 8c5a151d…) left a block-tail element read lazy. That is the #1968 bug, fixed in 9a73f74, which in the same commit changed math_fn_arity from t.get(id).arity to t[id].arity.
That seed's check --dump-mir of the shape fn arity(id): let t = table(); t[id].arity prints drop(_2) @ scope-exit; _0 = copy _2[_4].f. Its ir frees t before the bounds check, and run panics "index out of bounds". Its --validate-all says ok.
In the stage1 that seed built (impl-1930, 04:46; wave-d65c's 05:59 stage1 reproduces too), math_fn_arity frees the Vec, then always calls with_panic_ref (+164 bl with_vec_free_buffer_drop_origin, +196 bl with_panic_ref, brk). The optimizer folded the cleared length into the bounds check, so no path returns.
Stage2 and the release are built by stage1, whose lowering has the 9a73f74 fix, so they are correct.
The seed bump bc4772c (nightly-20261003, c884c1c, which contains 9a73f74) fixed it. On 74e3001 with that seed, stage1's math_fn_arity does cmp/b.le, load, drop, ret, and all four fixtures (d70 namespaces, math_builtins, 1874 simd, c_import inline math) pass under stage1. The reopen's stage1s predate the bump.
Why no tool caught it: validate-all has no read-after-drop rule. A dropped place is Uninit, the same as StorageDead, and the uninit-read rule never judges a projection. No lane runs the seed-built stage1 beyond compiling stage2.
#2050 adds the missing validator rule. It also fixes the one real hit the validator found in the corpus: raw-pointer tails (t[0].p, a facade's d.repr) were still left lazy and read after the drop with the release compiler.
Activity
ehartford commentedon Oct 3, 2026
Does not reproduce on main c884c1c: a stage1 built by the pinned seed and one built by the new darwin seed (nightly-20261003-local-1-c884c1c2a17c) both build examples/spiral to the program's real §4.2.6 error (
i / 140.0), no panic, matching the release compiler. Closed per Eric (2026-10-03); reopen with a repro if it returns.ehartford commentedon Oct 3, 2026
Reopened: the stage1-only 'index out of bounds' class reproduces again (2026-10-03, during #2043 work) on behav_d70_import_namespaces, math_builtins, behav_1874_simd_c_abi_darwin and behav_c_import_inline_math_builtin_call: panics under stage1 only, the same on the previous commit's stage1, passing on the release binary. Being fixed now.
ehartford commentedon Oct 3, 2026
Root cause, at the instruction level: the old pinned seed's lowering (nightly-20260929-local-2-c95ae12d9f64 =
v0.15.3.0-g8f84428e5, digest 8c5a151d…) left a block-tail element read lazy. That is the #1968 bug, fixed in 9a73f74, which in the same commit changedmath_fn_arityfromt.get(id).aritytot[id].arity.check --dump-mirof the shapefn arity(id): let t = table(); t[id].arityprintsdrop(_2) @ scope-exit; _0 = copy _2[_4].f. Itsirfreestbefore the bounds check, andrunpanics "index out of bounds". Its--validate-allsaysok.math_fn_arityfrees the Vec, then always callswith_panic_ref(+164 bl with_vec_free_buffer_drop_origin,+196 bl with_panic_ref,brk). The optimizer folded the cleared length into the bounds check, so no path returns.math_fn_aritydoes cmp/b.le, load, drop, ret, and all four fixtures (d70 namespaces, math_builtins, 1874 simd, c_import inline math) pass under stage1. The reopen's stage1s predate the bump.Why no tool caught it:
validate-allhas no read-after-drop rule. A dropped place is Uninit, the same as StorageDead, and the uninit-read rule never judges a projection. No lane runs the seed-built stage1 beyond compiling stage2.#2050 adds the missing validator rule. It also fixes the one real hit the validator found in the corpus: raw-pointer tails (
t[0].p, a facade'sd.repr) were still left lazy and read after the drop with the release compiler.MIR ownership validator: a read through a local every path dropped is…
MirLower: a block tail copying a raw-pointer field of a local the blo…
MIR ownership validator: a read through a local every path dropped is…
MirLower: a block tail copying a raw-pointer field of a local the blo…
#1991: read-after-drop MIR validator; raw-pointer block tails read be…
#3080: a str field read as a function's tail from an owned local retains
fix-ceremony: facts proven on the compiler, --check-with, and the src…