Fix compiler stack overflow#244
Open
malik672 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This updates the intermediate compiler lowering so the sequential continuation after a match, if, or function call is compiled iteratively instead of recursively re-entering compile_lines on the remaining tail of the block.
The generated aggregation program can contain long flat blocks with many control-flow splits. The old lowering recursively compiled the remaining tail for each continuation, which could exhaust the Rust compiler process stack during prover setup.
Root cause
compile_lines used recursion both for genuinely nested blocks and for the linear remainder of the same block. The latter made compile-time stack usage grow with the number of continuation splits in a flat generated program.
Fix
The function now tracks the root block and pending continuation label explicitly, then advances lines to the remaining tail inside an outer loop. Nested branches still compile recursively where the source structure is actually nested, but flat continuations no longer grow the host stack.
Validation
Note: the test build completed successfully; Cargo also printed a non-project warning about permission-denied cleanup of a global registry cache file.