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

Stack overflow for some source code input in debug mode #140

Open
JohnnyMorganz opened this issue Mar 5, 2021 · 8 comments
Open

Stack overflow for some source code input in debug mode #140

JohnnyMorganz opened this issue Mar 5, 2021 · 8 comments
Assignees

Comments

@JohnnyMorganz
Copy link
Collaborator

For some inputs (eg. JohnnyMorganz/StyLua#38, or other examples shown below), using full-moon produces a stack overflow. This is mostly noticeable in the debug version of full-moon, and is less likely to occur using the release version, but it is still possible.

Some other examples include:

coroutine.resume(coroutine.create(function(...)
    local succ, err = pcall(tryAPI)
    if not succ then
        local tryConnection; tryConnection = RunService.Stepped:Connect(function(_, delta, ...)
            accum += delta -- stack overflow at this compound assignment
        end)
    else
        
    end
end))

[Roblox Feature Flag - if you replace accum += delta with something else like local x = 1, it parses fine]

function API.getTags(class: string, member: string?): Array<string>
    if member then
        for _, v in ipairs(classTable.Members) do
            if v.Name == member then
                local tags: typeof(v.Tags) = v.Tags
                if tags then
                    for i, tag in ipairs(tags) do
                        -- stack overflow
                    end
                end
            end
        end
    else
        
    end
end

[Roblox Feature Flag - if we remove the first if statemenet and keep its body (if member then ... else end), it parses fine. If we remove all type information, but retain the roblox feature flag, there is a stack overflow. If we remove all type information and disable the roblox feature flag, it parses fine]

@Kampfkarren
Copy link
Owner

To be clear, have you ever gotten this on release optimizations, or is that just theoretical? If so, then my potential fix likely won't help.

@JohnnyMorganz
Copy link
Collaborator Author

JohnnyMorganz commented Mar 5, 2021

To be clear, have you ever gotten this on release optimizations, or is that just theoretical? If so, then my potential fix likely won't help.

JohnnyMorganz/StyLua#38 was done using a release version of StyLua. StyLua also works recursively though, starting at a block and recursively formatting until we reach a TokenReference - this may be compounding onto it?

EDIT: Actually I may need to double check this, as I remember asking the user to build from master as there a few unreleased fixes - they may have built the debug version.

@JohnnyMorganz
Copy link
Collaborator Author

Just tested this now, and it seems to be working fine using a release version of StyLua, so maybe it is only for the debug version
image

I will ask the user to confirm

@Kampfkarren Kampfkarren changed the title Stack overflow for some source code input Stack overflow for some source code input in debug mode Mar 17, 2021
@jeparlefrancais
Copy link
Contributor

By the way, if you want your debug build to not have that issue, you can specify to compile full_moon with release optimization even when you are building in debug or for tests. Just add these lines in you Cargo.toml file:

[profile.dev.package.full_moon]
opt-level = 3

I did this for darklua: https://gitlab.com/seaofvoices/darklua/-/blob/main/Cargo.toml

@zhiburt
Copy link
Contributor

zhiburt commented Oct 2, 2021

Hi @JohnnyMorganz I've tracked a disscussion for a couple of minutes and seems like you know what the issue is about?
But I did not found any place that the issue was actually described.
Or you are aware it exists but you don't know the cause behind?

@JohnnyMorganz
Copy link
Collaborator Author

I'm aware it exists, and I know the current workaround is just to use a release build instead.

@Kampfkarren looked more into the underlying cause, and I think they pinpointed something. I can't remember exactly what it was though

@Kampfkarren Kampfkarren self-assigned this Oct 3, 2021
@Kampfkarren
Copy link
Owner

Yeah, this is one I'm going to end up taking on my own at some point. I put a thread on the Rust forums and was told to use something called "stacker", which some official Rust products use internally to combat this kind of thing.

@JohnnyMorganz
Copy link
Collaborator Author

This seems to be no longer an issue if you update to the latest stable rust version!! 🚀

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

No branches or pull requests

4 participants