-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
There may be a problem with modestly deep recursion #5470
Comments
To make this issue a bit more standalone: Simply trying to parse the generated code in question with swc is able to hit the default 1MB main thread stack limit on Windows. It seems to be due to the deep nesting, combined with swc's use of a hand written recursive descent parser. Normally I would feel that such deep nesting is silly, and don't do that, but the fact that this is generated code by a commonly used parser generator, and that the grammar of the parser is not at all unreasonable are good counter arguments that this case needs to be supported. The fact that the nesting limit is so low on windows suggests the stack frames contain a lot of data, which probably should be slimmed down. This could potentially allow for parsers with even larger grammars, but there would still be a limit somewhere. Having some nesting limit due to the stack is pretty inherent to recursive descent parsers. The only real ways to avoid that are:
I'm not sure how necessary trying to solve this for all possible programs actually is. If the stack frame sizes can be improved enough, perhaps the limit becomes sufficiently large that nobody really cares. But perhaps trying to solve it fully is actually quicker and simpler. I'm not really sure what the overhead of rustc's approach actually is in practice. It might be small enough to be worth it to avoid further whack-a-mole with the stack size limits. |
It may be worth noting that I appear to be the second instance of a wall move on Windows. It may also be worth noting that swc already reduced stack frame size for Deno once (twice if you count debug builds,) suggesting that a more permanent solution may be warranted Admittedly, as a person Not Doing The Work ™, my opinion is of distinctly limited value here |
thank you @kdy1 |
This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think this was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you. |
this should not be closed i don't agree with the use of auto-close. it just hides problems that aren't easy to fix fast |
@kdy1 - I just saw the "need more info." Can I help? |
Also, there actually is a reproduction. How do I tell the bot that? |
Please file a new issue with the reproduction case |
Oh my bad I thought I left a comment for asking repro case |
I just closed this as reproducing a bug triggered by using Deno requires lots of time, so it's not a useful repro. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
Hi. I'm the author of some trivial domain-specific language for authoring finite state machines.
I tried to port my machine's implementation to Deno, and I hit ground pretty hard. Loading the library causes deno to crash.
After some back and forth, they suggest that the problem comes from swc, specifically from that my parser recurses occasionally several hundred times, and that apparently we're hitting stack size limits.
This is actually quite common with generated parsers, and the grammar for my language is barely 40k, most of which is simple lists eg the CSS colors; the parser is not very complex at all by parser standards, and the compiled version that's taking Deno down runs happily in Netscape Navigator 4.
The Deno folks recommended that I come here, and propose one or more of the following. I am not a Rustacean, and I don't really know what I'm saying here; please try not to laugh too hard.
They also propose, for themselves:
So, I'm bearing the torch. But I'm not a Deno person and as soon as you ask me questions I'm going to crumble under the lightest of loads. 😂
I'll do my best
Input code
Config
No idea. It's `Deno`.
Playground link
Repro link doesn't make sense because the code is over max-url length. However, cut and
Expected behavior
Uh. I don't really know, to be honest? I'm not your user here. The Deno developers are.
My understanding is that what's going on here is that
deno
usesswc
to perform static analysis and possibly more, and that the static analysis phase is where this is going south.And so, if I drop the compiled parser in your playground above (sorry about not giving a link, it's like 500k thanks to url encoding) then I do get the same result.
And I guess I think the answer is
"it should compile"
but that seems like kind of a smarmy thing to sayActual behavior
As best as I can tell, it's crashing due to legitimate stack out-of-bounds access, due to the significant depth of recursion.
It's crashing around 250 recurses down, in
Deno win64
, which I gather has a default 1 meg stack.And setting aside how funny it is that
Deno
's default stack is smaller than myemm386
configuration was back in the DOS days, also, I guess I feel like burning a meg to recurse 250 stack frames is a lot. That's 4k per frame.Owen Wilson saying wow.
The heap is pretty cool too
Version
no idea. current i think? don't really know how to check
Additional context
I know my bug report was terrible and I'm sorry
The text was updated successfully, but these errors were encountered: