Skip to content

ICE on constant x % 0 instead of erroring #415

Description

@jubnzv

When the operands of % are compile-time constants and the divisor is 0, circom aborts with an uncaught Rust panic instead of the graceful error[T3001]: Division by zero that \ and / emit for the same input.

MRE

pragma circom 2.1.0;
template Main() { signal output out; out <-- 17 % 0; }
component main = Main();
$ circom mod0.circom --wasm
thread 'main' panicked at num-bigint-dig-0.8.4/src/algorithms/div.rs:38:9:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
101

For comparison, \ and / on the same input report the error cleanly:

$ # out <-- 17 \ 0;  (and  out <-- 1 / 0;)
error[T3001]: Division by zero
$ echo $?
1

Environment

  • circom: 2.2.3 (a100fae)
  • rustc: 1.97.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions