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

Divide by zero in 9_conditional #1802

Closed
jfecher opened this issue Jun 22, 2023 · 3 comments · Fixed by #1951
Closed

Divide by zero in 9_conditional #1802

jfecher opened this issue Jun 22, 2023 · 3 comments · Fixed by #1951
Assignees
Labels
bug Something isn't working refactor ssa

Comments

@jfecher
Copy link
Contributor

jfecher commented Jun 22, 2023

Aim

Tried to prove and verify test 9_conditional with the --experimental-ssa flag

Expected Behavior

Expected the test to prove and verify

Bug

The program panics with:

The application panicked (crashed).
Message:  attempt to divide by zero
Location: ~/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.4.3/src/biguint/division.rs:70

This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.
If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 12 frames hidden ⋮                              
  13: num_bigint::biguint::division::rem_digit::hab9de1142251a43f
      at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.4.3/src/biguint/division.rs:70
  14: num_bigint::biguint::division::<impl core::ops::arith::Rem<u32> for &num_bigint::biguint::BigUint>::rem::h9f36fdba14c97c2f
      at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.4.3/src/biguint/division.rs:509
  15: num_bigint::biguint::division::<impl core::ops::arith::Rem<&num_bigint::biguint::BigUint> for &num_bigint::biguint::BigUint>::rem::h0f3ff2a5055a0e24
      at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.4.3/src/biguint/division.rs:484
  16: acvm::pwg::directives::solve_directives_internal::hd535679e0369505c
      at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/acvm-0.15.1/src/pwg/directives/mod.rs:61
  17: acvm::pwg::directives::solve_directives::hfbb5440f88e5e677
      at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/acvm-0.15.1/src/pwg/directives/mod.rs:27
  18: acvm::pwg::solve::h04119895763b2f4d
      at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/acvm-0.15.1/src/pwg/mod.rs:120
  19: nargo::ops::execute::execute_circuit::hf1d169eb4c52d7a1
      at noir/crates/nargo/src/ops/execute.rs:14
  20: nargo_cli::cli::execute_cmd::execute_program::hfab95fe37eeca478
      at noir/crates/nargo_cli/src/cli/execute_cmd.rs:82
  21: nargo_cli::cli::prove_cmd::prove_with_path::h552b36acab6b610f
      at noir/crates/nargo_cli/src/cli/prove_cmd.rs:125
  22: nargo_cli::cli::prove_cmd::run::h01a47cfb101544d5
      at noir/crates/nargo_cli/src/cli/prove_cmd.rs:65
  23: nargo_cli::cli::start_cli::hdf9ebb41a12edf18
      at noir/crates/nargo_cli/src/cli/mod.rs:77
  24: nargo::main::h4caa4dc2a2c3a0a7
      at noir/crates/nargo_cli/src/main.rs:14
  25: core::ops::function::FnOnce::call_once::hd5f7091a178804ee
      at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251
                                ⋮ 13 frames hidden ⋮                              
exit 101

To Reproduce

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@jfecher jfecher added the bug Something isn't working label Jun 22, 2023
@kevaundray kevaundray changed the title (SSA Refactor): Divide by zero in 9_conditional Divide by zero in 9_conditional Jun 23, 2023
@jfecher
Copy link
Contributor Author

jfecher commented Jun 23, 2023

Looks like this is caused by the parameter a of main being set to 0 in the Prover.toml. We produce a div instruction using it:

fn main f0 {
  b0(v0: Field, ..):
    ..
    v33601 = div v33442, v0
    ..

The error is while running execute_cmd so I'm not sure why it is only occurring now.

@kevaundray
Copy link
Contributor

kevaundray commented Jul 14, 2023

a minified example of this problem would be:

use dep::std;

fn main(a: u32, b: u32) ->pub u32{
    b / a % a
}

@kevaundray
Copy link
Contributor

Seems the error is in the quotient directive:

.cargo/registry/src/github.com-1ecc6299db9ec823/acvm-0.18.1/src/pwg/directives/mod.rs:64

This line in particular:

 (&int_a % &int_b, &int_a / &int_b)

Where int_b is zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor ssa
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants