Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal recursion limit triggered when not retaining full type graphs #975

Closed
JohnnyMorganz opened this issue Jul 11, 2023 · 2 comments · Fixed by #1008
Closed

Internal recursion limit triggered when not retaining full type graphs #975

JohnnyMorganz opened this issue Jul 11, 2023 · 2 comments · Fixed by #1008
Labels
bug Something isn't working

Comments

@JohnnyMorganz
Copy link
Contributor

JohnnyMorganz commented Jul 11, 2023

Reproducible file: https://github.com/evaera/roblox-lua-promise/blob/v4.0.0/lib/init.lua (must be in strict mode)

When performing a Frontend::check() on the above file, with retainFullTypeGraphs = false, an Internal Recursion Counter limit exceeded exception is raised.

Attaching a debugger to the process, the offending location seems to be the copyErrors() call below:
https://github.com/Roblox/luau/blob/e25de95445f2d635a125ab463426bb7fda017093/Analysis/src/Frontend.cpp#L950-L972

The visit call inside copy errors is creating an infinite loop, which gets terminated by the recursion limiter.

EDIT: stepping through the call stack, I don't think its actually an infinite loop, just a very deep error copying that gets terminated by the recursion limiter

@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label Jul 11, 2023
@vegorov-rbx
Copy link
Collaborator

I think the best we can do here is to replace errors that can't be cloned with a CodeTooComplex error.

JohnnyMorganz added a commit to JohnnyMorganz/luau-lsp that referenced this issue Jul 15, 2023
@alexmccord
Copy link
Member

I ended up replacing the cloning logic so that it isn't recursive anymore. A fix for this will be coming in the next sync.

Note that the iteration limit of 100,000 types to be cloned is arbitrary, and will probably need more fine-tuning.

vegorov-rbx added a commit that referenced this issue Aug 11, 2023
* Better indentation in multi-line type mismatch error messages
* Error message clone can no longer cause a stack overflow (when
typechecking with retainFullTypeGraphs set to false); fixes
#975
* `string.format` with %s is now ~2x faster on strings smaller than 100
characters

Native code generation:
* All VM side exits will block return to the native execution of the
current function to preserve correctness
* Fixed executable page allocation on Apple platforms when using
hardened runtime
* Added statistics for code generation (no. of functions compiler,
memory used for different areas)
* Fixed issue with function entry type checks performed more that once
in some functions
RomanKhafizianov added a commit to RomanKhafizianov/luau that referenced this issue Nov 27, 2023
* Better indentation in multi-line type mismatch error messages
* Error message clone can no longer cause a stack overflow (when
typechecking with retainFullTypeGraphs set to false); fixes
luau-lang/luau#975
* `string.format` with %s is now ~2x faster on strings smaller than 100
characters

Native code generation:
* All VM side exits will block return to the native execution of the
current function to preserve correctness
* Fixed executable page allocation on Apple platforms when using
hardened runtime
* Added statistics for code generation (no. of functions compiler,
memory used for different areas)
* Fixed issue with function entry type checks performed more that once
in some functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants