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

Stack overflow when having loops containing if statements #4449

Closed
guipublic opened this issue Feb 28, 2024 · 0 comments · Fixed by #4492
Closed

Stack overflow when having loops containing if statements #4449

guipublic opened this issue Feb 28, 2024 · 0 comments · Fixed by #4492
Assignees
Labels
enhancement New feature or request

Comments

@guipublic
Copy link
Contributor

Problem

The PR AztecProtocol/aztec-packages#4571 is failing CI because it reaches a stack overflow during the ssa flatenning.
I managed to get a minimal repro with the following code:

fn main(x: u8, result: [u8; 32]) {
    let mut digest = [0;32];
    for i in 0..70 {
        let y = x+i;
    let a = [y ,x,32,0,y+1,y-1,2*y,5];
    digest = std::sha256::digest(a);
    }

    assert(digest == result);
}

Happy Case

The flattening pass is using recursion and should be changed into an iterative version

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@guipublic guipublic added the enhancement New feature or request label Feb 28, 2024
@guipublic guipublic self-assigned this Feb 28, 2024
github-merge-queue bot pushed a commit that referenced this issue Mar 7, 2024
# Description

## Problem\*

Resolves #4449 

## Summary\*

The issue is fixed by implementing an iterative version of the
flattening pass.

## Additional Context



## 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.

---------

Co-authored-by: jfecher <jake@aztecprotocol.com>
github-merge-queue bot pushed a commit that referenced this issue Mar 7, 2024
# Description

## Problem\*

Related to issue #4449 

## Summary\*
This PR adds a regression test which ensure PR #4492 is able to handle
large CFG.


## Additional Context



## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant