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 panic when using the data bus feature #4046

Closed
Tracked by #3015
ggiraldez opened this issue Jan 15, 2024 · 0 comments · Fixed by #4047
Closed
Tracked by #3015

Compiler panic when using the data bus feature #4046

ggiraldez opened this issue Jan 15, 2024 · 0 comments · Fixed by #4047
Labels
bug Something isn't working

Comments

@ggiraldez
Copy link
Contributor

Aim

When compiling multiple functions and using the data bus feature, the compiler fails with this error:

The application panicked (crashed).
Message:  index out of bounds: the len is 3 but the index is 3
Location: compiler/noirc_evaluator/src/ssa/opt/inlining.rs:211

Expected Behavior

The compiler should not crash.

Bug

This happens because the code that saves the data bus configuration during SSA gen phase is incorrectly placed after processing all other functions. As such, it saves the configuration to the last compiled function instead of the main function.

To Reproduce

Given this program:

use dep::std;

fn main(mut x: u32, y: call_data u32, z: call_data [u32;4]) -> return_data u32 {
  let a = z[x];
  a+foo(y)
}

// Use an unconstrained function to to avoid the compiler inlining it
unconstrained fn foo(x: u32) -> u32 {
  x+1
}

Compile the program with nargo compile. The compiler will panic with the error mentioned above.

Installation Method

Binary

Nargo Version

nargo version = 0.22.0 noirc version = 0.22.0+420a5c74a14dcfeede04337a42282093a7b5e63e (git version hash: 420a5c7, is dirty: false)

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@ggiraldez ggiraldez added the bug Something isn't working label Jan 15, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jan 15, 2024
kevaundray pushed a commit that referenced this issue Jan 22, 2024
…rs (#4047)

# Description

## Problem\*

Resolves #4046 

## Summary\*

This PR changes saves the data bus configuration before processing the
other queued functions during SSA gen phase.

## Additional Context

With the current implementation the databus will be incorrectly saved to
the last generated function instead of the main function, causing a
panic in a later optimization phase.

## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jan 22, 2024
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
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant