Skip to content

Fix compiler stack overflow#244

Open
malik672 wants to merge 1 commit into
leanEthereum:mainfrom
malik672:overflow
Open

Fix compiler stack overflow#244
malik672 wants to merge 1 commit into
leanEthereum:mainfrom
malik672:overflow

Conversation

@malik672
Copy link
Copy Markdown
Contributor

@malik672 malik672 commented Jun 2, 2026

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

  • cargo check -p lean_compiler -p rec_aggregation
  • cargo test --test test_multisignatures --no-run

Note: the test build completed successfully; Cargo also printed a non-project warning about permission-denied cleanup of a global registry cache file.

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

Successfully merging this pull request may close these issues.

1 participant