Skip to content

Keep the recursion check on light-throw targets - #2210

Draft
romangolev wants to merge 2 commits into
IronLanguages:mainfrom
pyrevitlabs:fix/light-throw-target-recursion-check
Draft

romangolev wants to merge 2 commits into
IronLanguages:mainfrom
pyrevitlabs:fix/light-throw-target-recursion-check

Conversation

@romangolev

@romangolev romangolev commented Dec 4, 2026 •

Copy link
Copy Markdown

A function that raises more than 20 exceptions is recompiled in the background for light exceptions. The recompiled target replaced the normal one without AddRecursionCheck, so a recursion limit set before the compile was not enforced for calls made from light-throw code (for example in eval). Deep recursion overflowed the stack instead of raising RecursionError.

The light-throw target of a function now gets the check like the normal target. The test runs in a new process on a 256 KB thread; without the change the process dies with a stack overflow. Tested locally on net8.0.

Related to #1611: this restores the check in one case where the limit was not enforced, but not the general stack usage that issue describes. It does not change the overflow in #2186, which still occurs with -X MaxRecursion set.

Light-throw targets compiled after a recursion limit was set skipped the check. Refs IronLanguages#1611.
@romangolev

Copy link
Copy Markdown
Author

@dotnet-policy-service agree company="pyrevitlabs"

With a recursion limit set, check the real stack in FunctionPushFrame so deep calls on small-stack threads raise RecursionError rather than crash.
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