quil-lang / quilc

The optimizing Quil compiler.
Apache License 2.0
452 stars 73 forks source link

Stack overflow on very long inputs #855

Open markasoftware opened 1 year ago

markasoftware commented 1 year ago

This is clearly evident when running the QASM benchmark suite, specifically 9symml_195.qasm. The problem is in process-includes, which uses tail recursion to loop over all the instructions. One solution is to add a local declare form to process-includes increasing the speed optimization to ensure that it uses tail recursion by default (at least in SBCL). Another solution is to use a loop. And the final option is to do nothing at all and assume any circuit long enough to exhaust the stack is simply too long for Quilc (since it blows the heap on my machine during addressing on this 9symml_195.qasm anyway)