iden3/circom

Input Signal Len Bug during Compile Step

Shadow-Silhouette opened this issue · 1 comments

Bug Report

Description

When introducing more than 256 input signals, the circom compiler panics and does not exit gracefully.
As a user of the circom compiler, I expect the compiler to exit gracefully and provide a meaningful error message.

Example Circuit

bug.circom

pragma circom 2.1.8;

template Example() {
signal input a1;
signal input a2;
signal input a3;
signal input a4;
signal input a5;
signal input a6;
signal input a7;
signal input a8;
signal input a9;
signal input a10;
signal input a11;
signal input a12;
signal input a13;
signal input a14;
signal input a15;
signal input a16;
signal input a17;
signal input a18;
signal input a19;
signal input a20;
signal input a21;
signal input a22;
signal input a23;
signal input a24;
signal input a25;
signal input a26;
signal input a27;
signal input a28;
signal input a29;
signal input a30;
signal input a31;
signal input a32;
signal input a33;
signal input a34;
signal input a35;
signal input a36;
signal input a37;
signal input a38;
signal input a39;
signal input a40;
signal input a41;
signal input a42;
signal input a43;
signal input a44;
signal input a45;
signal input a46;
signal input a47;
signal input a48;
signal input a49;
signal input a50;
signal input a51;
signal input a52;
signal input a53;
signal input a54;
signal input a55;
signal input a56;
signal input a57;
signal input a58;
signal input a59;
signal input a60;
signal input a61;
signal input a62;
signal input a63;
signal input a64;
signal input a65;
signal input a66;
signal input a67;
signal input a68;
signal input a69;
signal input a70;
signal input a71;
signal input a72;
signal input a73;
signal input a74;
signal input a75;
signal input a76;
signal input a77;
signal input a78;
signal input a79;
signal input a80;
signal input a81;
signal input a82;
signal input a83;
signal input a84;
signal input a85;
signal input a86;
signal input a87;
signal input a88;
signal input a89;
signal input a90;
signal input a91;
signal input a92;
signal input a93;
signal input a94;
signal input a95;
signal input a96;
signal input a97;
signal input a98;
signal input a99;
signal input a100;
signal input a101;
signal input a102;
signal input a103;
signal input a104;
signal input a105;
signal input a106;
signal input a107;
signal input a108;
signal input a109;
signal input a110;
signal input a111;
signal input a112;
signal input a113;
signal input a114;
signal input a115;
signal input a116;
signal input a117;
signal input a118;
signal input a119;
signal input a120;
signal input a121;
signal input a122;
signal input a123;
signal input a124;
signal input a125;
signal input a126;
signal input a127;
signal input a128;
signal input a129;
signal input a130;
signal input a131;
signal input a132;
signal input a133;
signal input a134;
signal input a135;
signal input a136;
signal input a137;
signal input a138;
signal input a139;
signal input a140;
signal input a141;
signal input a142;
signal input a143;
signal input a144;
signal input a145;
signal input a146;
signal input a147;
signal input a148;
signal input a149;
signal input a150;
signal input a151;
signal input a152;
signal input a153;
signal input a154;
signal input a155;
signal input a156;
signal input a157;
signal input a158;
signal input a159;
signal input a160;
signal input a161;
signal input a162;
signal input a163;
signal input a164;
signal input a165;
signal input a166;
signal input a167;
signal input a168;
signal input a169;
signal input a170;
signal input a171;
signal input a172;
signal input a173;
signal input a174;
signal input a175;
signal input a176;
signal input a177;
signal input a178;
signal input a179;
signal input a180;
signal input a181;
signal input a182;
signal input a183;
signal input a184;
signal input a185;
signal input a186;
signal input a187;
signal input a188;
signal input a189;
signal input a190;
signal input a191;
signal input a192;
signal input a193;
signal input a194;
signal input a195;
signal input a196;
signal input a197;
signal input a198;
signal input a199;
signal input a200;
signal input a201;
signal input a202;
signal input a203;
signal input a204;
signal input a205;
signal input a206;
signal input a207;
signal input a208;
signal input a209;
signal input a210;
signal input a211;
signal input a212;
signal input a213;
signal input a214;
signal input a215;
signal input a216;
signal input a217;
signal input a218;
signal input a219;
signal input a220;
signal input a221;
signal input a222;
signal input a223;
signal input a224;
signal input a225;
signal input a226;
signal input a227;
signal input a228;
signal input a229;
signal input a230;
signal input a231;
signal input a232;
signal input a233;
signal input a234;
signal input a235;
signal input a236;
signal input a237;
signal input a238;
signal input a239;
signal input a240;
signal input a241;
signal input a242;
signal input a243;
signal input a244;
signal input a245;
signal input a246;
signal input a247;
signal input a248;
signal input a249;
signal input a250;
signal input a251;
signal input a252;
signal input a253;
signal input a254;
signal input a255;
signal input a256;
signal input a257;

signal output b1;

b1 <== a257 * a256;
}

component main = Example();

Steps to Reproduce

  1. Create a circuit with more than 256 input signals.
  2. Compile the circuit with the circom compiler:
    circom ./path/to/bug.circom --r1cs --wasm --sym --c -o ./target/compiled/

Expected Behavior

The compiler should exit gracefully and provide a meaningful error message or allow any number of input signals if there is no technical limitation behind that behaviour.
Also, the cpp artifacts are generated which should probably not be the case on error.

Actual Behavior

Error (circom compiler):

thread 'main' panicked at 'assertion failed: signal_name_list.len() <= 256', code_producers/src/c_elements/c_code_generator.rs:473:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Environment

  • Circom version: 2.1.8

Thanks for reporting this situation.
Instead of catching the panic case, in the new release 2.1.9, we have allowed the programmer to define any number of different input signal names in the main component. So, it should compile correctly now.