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

Insufficient memory allocation in C++ generated code #287

Open
olomix opened this issue Aug 12, 2024 · 0 comments
Open

Insufficient memory allocation in C++ generated code #287

olomix opened this issue Aug 12, 2024 · 0 comments

Comments

@olomix
Copy link
Contributor

olomix commented Aug 12, 2024

I have found a place where generated C++ code uses array element out of bound.

Steps to reproduce. There is a SMTLevIns template in the circomlib repository: https://github.com/iden3/circomlib/blob/master/circuits/smt/smtlevins.circom

We create a simple circuit circuit1.circom

pragma circom 2.0.0;

include "smt/smtlevins.circom";
include "comparators.circom";

component main = SMTLevIns(40);

And compile it using recent circom version to C++ code:

circom -c -l "<path_to_circomlib>/circuits" circuit1.circom

If we take a look at the SMTLevIns_1_run function inside the generated circuit1_cpp/circuit1.cpp file we can see that there is a variable declaration

FrElement expaux[4];

And later in the code we are trying to use the 5th element of this 4-element long array:

Fr_sub(&expaux[4],&lvar[1],&circuitConstants[1]); // line circom 98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant