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

Infinite recursion when parsing bad AstStatDeclareClass (definition file) #1520

Open
JohnnyMorganz opened this issue Nov 10, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@JohnnyMorganz
Copy link
Contributor

Originally reported by @coderedart in JohnnyMorganz/luau-lsp#756


declare class Widget
    state: {string: function(string, Widget)}
end

If I copy paste the above text into a type definition file and reload the lsp, luau-lsp starts leaking memory at around 100MB+ per second until the system runs out of ram.

The culprit seems to be {string: function(string, Widget)}. The syntax is probably wrong. If I use (string, Widget) -> nil instead, there's no leak.

But just wanted to report the leak anyway, as someone else might fumble into this issue.


I moved this to Luau since I can repro it in Luau's codebase with

TEST_CASE_FIXTURE(Fixture, "test")
{
    LoadDefinitionFileResult result = loadDefinition(R"(
        declare class Widget
            state: {string: function(string, Widget)}
        end
    )");
}
@hgoldstein
Copy link
Contributor

Thanks for the report; digging in a bit I think what's happening is that when we attempt to parse this type, we error, and the error recovery doesn't move us past the error, so we just continually parse properties until Luau gets ... OOM killed I suppose.

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

No branches or pull requests

2 participants