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

nickel doc overflows the stack with recursive schemas #1967

Closed
yannham opened this issue Jun 19, 2024 · 2 comments · Fixed by #2055
Closed

nickel doc overflows the stack with recursive schemas #1967

yannham opened this issue Jun 19, 2024 · 2 comments · Fixed by #2055

Comments

@yannham
Copy link
Member

yannham commented Jun 19, 2024

Describe the bug
nickel doc aborts with a stack overflow on a real-world 1MB Nickel schema, which doesn't look very deep (nickel doc does use recursive calls, but the stack space should be linear in the depth of the schema, roughly).

To Reproduce
I unfortunately can't provide the test case, which has been provided as a courtesy but isn't public. This issue is mostly a reminder to investigate it.

@yannham
Copy link
Member Author

yannham commented Jun 21, 2024

We do have a MRE, and it seems it doesn't have anything to do with schema size, but everything to do with recursive contracts:

{
  Recursive = {
    foo | Number,
    bar | Recursive | optional
  }
}

@yannham yannham changed the title nickel doc overflows the stack on large-ish schemas nickel doc overflows the stack with recursive schemas Jun 21, 2024
@yannham
Copy link
Member Author

yannham commented Jul 4, 2024

I think we had the exact same problem in the LSP (not for documentation, but for elaborating e.g. completion information). One simple and stupid solution was to set a recursion limit there.

However, I don't think that would work very well for documentation, because that will result in unrolling the definition of Recursive max_depth times, which is not what one's want. So we need a way to keep track of things that we've already processed (or are processing), and decide to not unfold those definitions. I wonder if we can reuse the logistics of thunks to do so.

cc @Quantum64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant