chore: reproduce ACIR-gen ICE on a constant index known only to ACIR gen (AST fuzzer) - #13444
Draft
AztecBot wants to merge 1 commit into
Draft
chore: reproduce ACIR-gen ICE on a constant index known only to ACIR gen (AST fuzzer)#13444AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a load-bearing reproduction (no fix) for the AST fuzzer
acir_vs_brilligfailure on seed0xabdfa2be00100000againstmaster(d89d99a944). This one is a compiler ICE, the most serious of the three seeds from that run.The bug
The reduced program reads an array at an index that is not an SSA constant but is a compile-time constant known only to ACIR gen:
v3is not an SSA numeric constant, sohandle_constant_index_wrapper(compiler/noirc_evaluator/src/acir/arrays.rs) — which only checksdfg.get_numeric_constant— falls through to the dynamic memory-op path. But whenconstrain u1 0 == v0is lowered,assert_eq_varrewritesv0's witness to the constant0, and the cast +unchecked_addfold, so the index is the constant2in ACIR. ACIR gen then emits aMemoryInit+MemoryOp::Readat a constant index into a block that is never written — exactly the patternassert_constant_reads_are_folded(compiler/noirc_evaluator/src/acir/mod.rs, added in #13229) rejects, hence the panic.The reproduction
acir::tests::arrays::constant_index_known_only_to_acir_gen_icesfeeds the minimal SSA above throughssa_to_acir_program, which panics onmaster. It is marked#[should_panic(expected = "ICE: Read resolving to a compile-time constant …")]so it documents the crash deterministically; once ACIR gen consults its own constant tracking (var_to_constant) when choosing the compile-time read path, it stops panicking and the#[should_panic]should be removed.Severity
High. A hard compiler crash reachable from ordinary source — any program with an index that becomes constant only after a constraint proves an input's value.
Related issues
Refs noir-lang/noir-claude#1558
This PR closes nothing — it is reproduction-only, adds a failing-by-design test, and changes no compiler behaviour, so #1558 stays open after it merges. The closing keyword belongs on the fix PR. (It would not auto-close in any case: GitHub only auto-closes issues in the PR's own repo.)
noir-claude#1558 is the same defect, filed one day before this fuzzer run:
Same assertion, same declining gate (
arrays.rs,dfg.get_numeric_constant), same unfoldedread_from_memory. It differs only in how the index becomes constant inside ACIR gen: #1558 reaches it by expression-algebra cancellation (a[p0.wrapping_sub(p0)]lowering to(v6 + 2¹²⁸) - v6), this seed byconstrain-driven witness substitution. The fix suggested here (consultvar_to_constantat the gate) and the one in #1558 (fold inread_from_memory/array_get_value) address the two halves of the same defect. #1558 also reports the AST fuzzer tripping this at ~0.56% of random expression programs, so this seed is very likely one of that population.Related but distinct: noir-claude#1527 (a different defect in the same #13229 predicated-access machinery this assertion guards) and closed noir-claude#1474 (the sibling debug-only ACIR post-check ICE, since fixed). No open AST Fuzzer issue in this repo covers it.
Full RCA + a suggested fix: https://gist.github.com/AztecBot/c17280a14270f2b29be10177e7b41227
Created by claudebox · group:
slackbot· requested by Tom French · Slack thread