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

Instruction::MakeArray deduplication is incompatible with mutating arrays in unconstrained code #6680

Open
jfecher opened this issue Dec 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Dec 2, 2024

Aim

fn main(x: Field, y: pub Field) {
    let qs = [0];

    let mut dynamic = [0];
    dynamic[x] = 1000;

    println(qs.as_slice()); // &[0]
    println(as_slice_push(qs)); // (loop to create a slice from qs): &[0]
}

Expected Behavior

The above code to run with the slices given in comments to be printed

Bug

In ssa, dynamic gets deduplicated to the same make_array instruction as qs. This occurs in master and is potentially problematic.

This latent issue was made easier to trigger failing cases for in #6607 since reference counts were changed to effectively start at 1 instead of 2 so these arrays are actually being mutated now. This issue is still present on master though, just more difficult to trigger.

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

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
Status: 📋 Backlog
Development

No branches or pull requests

1 participant