Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler panics on out-of-bounds array accesses #471

Closed
jfecher opened this issue Nov 15, 2022 · 0 comments · Fixed by #673
Closed

Compiler panics on out-of-bounds array accesses #471

jfecher opened this issue Nov 15, 2022 · 0 comments · Fixed by #673
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Nov 15, 2022

Description

Aim

Attempted to write an invalid noir program:

fn main(y: [u32; 5]) {  
    constrain y[6] == 2;
}

Expected behavior

Compiler will issue an error explaining that an out-of-bounds array access has occurred with the original source location of the error, the index value, and the array length.

Bug

Compiler hits an unreachable expression and panics:

thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 6', crates/noirc_evaluator/src/ssa/anchor.rs:137:13
stack backtrace:
   0: rust_begin_unwind
   [...]

To reproduce

  1. Run the example code above with nargo prove p

Additional context

The current panic message is fine, but being issued from a panic is confusing to users since calls to unreachable are usually indicative of a compiler crash rather than an intended error reporting. We should thread Location data down to these Load/Store instructions in SSA so that we can issue an error in the same format as other compiler errors.

@jfecher jfecher added the bug Something isn't working label Nov 15, 2022
kevaundray pushed a commit that referenced this issue Jan 31, 2023
* Handle out-of-bound errors in CSE

* Code review

* Code review - removes the CseAction error

* Code review

* fix clippy error
TomAFrench added a commit that referenced this issue Feb 3, 2023
* master:
  Rename methods that use `conditionalize` to be more descriptive (#739)
  feat(noir)!:  Returned values are no longer required by the prover (#731)
  chore: explicit versions for dependencies (#727)
  chore: readability improvements (#726)
  feat(nargo): include short git commit in cli version output (#721)
  Remove print to console for named proofs in `nargo prove` (#718)
  chore: clean up serde-related dependencies (#722)
  Handle out-of-bound errors in CSE (#471) (#673)
  Remove unused dependencies and only use workspace inheritance on shared deps (#671)
  feat(std_lib)!: modulus bits/bytes methods, and to_bits -> to_le_bits (#697)
  Implement numeric generics (#620)
  Review some TODO in SSA (#698)
  Replace `toml_map_to_field` and `toml_remap` with traits to map between `InputValue`s and `TomlTypes` (#677)
  Apply witness visibility on a parameter level rather than witness level (#712)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant