Skip to content

fix(ssa): Add MAX_INTERPRETER_CALL_STACK_SIZE to SSA interpreter#11264

Merged
TomAFrench merged 4 commits intomasterfrom
af/8081-infinite-recur-lambda
Jan 20, 2026
Merged

fix(ssa): Add MAX_INTERPRETER_CALL_STACK_SIZE to SSA interpreter#11264
TomAFrench merged 4 commits intomasterfrom
af/8081-infinite-recur-lambda

Conversation

@aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Jan 20, 2026

Description

Problem

Resolves #8081

Summary

Adds a MAX_INTERPRETER_CALL_STACK_SIZE constant with a value of 1000 to the SSA interpreter. If this is reached during Interpreter::call_function then we return a new InterpreterError::StackOverflow with the IDs and names of the functions on the call stack.

Additional Context

Unlike the comptime interpreter, we can go 1000 deep here, matching ACIR.

The issue originally was created when the Inlining pass overflowed the stack on the example program, because it was trying to inline an infinitely recursive ACIR lambda into a Brillig function. This was before the lambdas were changed to be represented by a pair of (constrained, unconstrained) functions. Now it's inlining a Brillig lambda into a Brillig function, which has handling to prevent recursion.

The problem was now with the constant folding: since the arguments were constant, we tried to interpret the call using the SSA interpreter, and while #10481 limited the number of steps taken during constant folding to prevent infinite loops, it didn't limit the stack size, which was easier to exhaust.

User Documentation

Check one:

  • No user documentation needed.
  • Changes in docs/ included in this PR.
  • [For Experimental Features] Changes in docs/ to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@aakoshh aakoshh requested a review from a team January 20, 2026 00:06
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 72ea03c Previous: 67478b2 Ratio
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob 248 s 203 s 1.22

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@TomAFrench TomAFrench added this pull request to the merge queue Jan 20, 2026
Merged via the queue into master with commit be8004d Jan 20, 2026
135 checks passed
@TomAFrench TomAFrench deleted the af/8081-infinite-recur-lambda branch January 20, 2026 13:20
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.

Compiler crash inlining recursive lambda

2 participants