-
Notifications
You must be signed in to change notification settings - Fork 30
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
v0.6.2 release fails with "maximum call stack size exceeded" #84
Comments
Thanks. I think we plan to spend a bit of time on this after we upgrade to Elm 0.17 sometime around December. For now, we just use a little script to boot Chrome with a bigger stack:
|
Still crashing |
Hi! Yep—it's still crashing without the script Brian mentioned. I was actually just looking into this issue yesterday, and it turns out that what causes the slow load time and the stack overflow error is the parser for the language. We're still working on / aware of this issue, but thanks for the feedback! |
So in attempting to get unit-tests compiling (and passing!) again, I pulled @jlubi333 's fix-tests branch referenced here down and started porting the tests over to the apparently standard elm-test package. Sort of intriguingly, the first test I ported explodes with the maximum call stack size exceeded. If anyone is interested, the base changes are here: amzuko@1b297d3 . Intriguingly, some googling revealed elm/compiler#1521, which would point towards long list literals potentially generating this behavior. I haven't found any examples of that in the parser, which previous comments in this thread point towards as a culprit. The other suspect I considered is the prelude; this is fairly substantial little program that then passes through the parser combinator defined src/OurParser2.elm. I definitely have not grokked the various combinators defined in OurParser, but it seems at least plausible that there's some recursion going on there that depends on the length of the program, rather than expression depth -- does this match the core maintainers' intuition over where the problem lies? This is further reinforced by the simple experiment in amzuko@c93299e, which tears out the prelude and replaces it with a dummy. With this substitution, simple parsing tests pass, and we can reliably generate a stack explosion by passing a large program into the parser. Glancing through src/LangParser2.elm, it seems that there is a high level of coupling between language constructs (control statements), syntactic extensions to basic s-expressions (widgets, freezing), and the contents of the prelude. Intuitively, I would have expected this to be broken into a few stages of tokenization/lexing, and parsing into an AST then passed on for type checking and execution. Out of curiosity, is there a conscious design choice behind this, or is this coupling more the result of rapid organic growth? My next guess on debugging this would be to inspect the individual combinators in OurParser2 that the little parser is built on to see if one or more is behaving badly and could be fixed. Failing that, I would probably attempt to blanket the little parser in tests and migrate it to a multi-stage parser that would let us better isolate individual operations. Any thoughts? |
Thank you very much for your investigative work! Regarding the long list literals: this is what I suspect is causing the problem as well. A couple weeks ago, I tried paring down the prelude file (which is loaded each time Sketch-n-Sketch starts), and the stack overflow error went away. This leads me to believe that it is definitely based on the length of the program. It's great to hear that someone else arrived at the same conclusion! Regarding the parser: it is indeed a bottleneck. I've only been working on Sketch-n-Sketch for ~3 months, so I don't know the origin story of the parser, but I believe that its structure is due to "rapid organic growth" :-) The reason for this is that the focus of this project is not so much on the particular implementation of Little (we, in fact, wish to transition to a "real" programming language like Elm one day for our editor), but rather on the high-level manipulation and interface between code and output. In other words, the parser has been working Good Enough™ for our purposes. Anyway, I actually am going to be completely re-writing the parser (hopefully) in about a week or so. However, I have final exams right now, so unfortunately I am just the slightest bit preoccupied :-) Thanks again! |
Learning a new syntax is one of the frustrating aspects of starting to work with Sketch-n-Sketch is the custom language of Little. I would be delighted by a pivot to Elm, however being new to the language, I'm not clear on how hard this would be. From what I can tell, the Little language requires the following macros (I think they're called macros?):
How hard would it be to parse these as part of a DSL of Elm? How much additional friction would it cause to replace these with normal function calls like I guess another problem would be dealing with the fact that Elm is strongly typed? P.S. you should probably change the title of this issue to note that this issue still occurs in version 6.0 |
We are aware that learning Little is one of the biggest hurdles in using Sketch-n-Sketch, and will hopefully be transitioning to Elm soon. It is most certainly on our radar, but it would actually be quite a large project due to the program synthesis backend. And thanks—I will update the title of the issue! |
@jlubi333 How's that parser rewrite going, by the way? |
Almost completed! You can check it out in the elm-tools-parser branch. I had it working very fast and with no stack size error... but then I added one more feature (tracking the position of each expression) and it requires a slightly larger stack than the default for the additional nesting of functions. I'm unsure exactly why it's going through the stack so quickly, but I have a couple of ideas in mind for how to fix it. Anyway, In the upcoming week or so, I should be able to finish off the project and incorporate it into the master branch. |
Great to hear!
|
I'll address each of your comments individually :-)
Thanks for your input on this! |
@jlubi333 thank you so much for your effort and please let me know when you've completed this overhaul! I would like to build something on top of Sketch-n-Sketch (no points talking about the project when I don't have code) and a better parser would make the undertaking much easier. |
That's awesome! We'd love to hear about what you make if you do end up building off of Sketch-n-Sketch! :-) |
Hi everyone — this is fixed in v0.6.1. It only took an entire parser rewrite! :-) |
I'm getting similar recursion problems in FF 57.0.1 and Chromium (SnS 0.6.1 and 0.6.2).
Chromium logs:
|
Well this is strange... it's not working for me either now. I'm reasonably confident that it was working a couple of days ago. Out of curiosity, when did you first try to load Sketch-n-Sketch and get that error? |
I started today and I couldn't get it working at all |
Okay, thank you. We will look into this ASAP! |
This appears to be a platform-specific issue. In my tests, Sketch-n-Sketch appears to work on macOS and Linux, but not on Chrome OS. I don't have a Windows machine to test the program right now, but I suspect that it does crash on Windows. We'll do our best to fix this issue! Thanks for the helpful feedback, everyone. |
I tried |
Interesting, thank you. May I ask what operating system you are running these browsers in? |
I'm on NixOS 18.03.git.a455d93 |
Thanks! We'll try to isolate the issue and fix it. |
I managed to isolate and fix this bug in the branch I'm on. To solve this error, I had to split two long list literals in two that were in the file Which branch should I push this bug fix to in priority? |
Nice find. You can put the fix on master (or any branch, really) and we'll cherry-pick it as needed. |
Fixed in 4db23af |
Prior issues were with our little parser (not the browser's). Going to leave this open for a bit longer until we are confident those problems are also resolved... |
For what it's worth, Sketch-n-Sketch still doesn't load on Chrome OS version 62.0.3202.97 (64-bit). |
at the same time, nobody pushed the version of master to
https://ravichugh.github.io/sketch-n-sketch/releases/v0.6.2/
(I investigated sns.js there and it was not updated with the fix)
Did you try it locally?
Le ven. 29 déc. 2017 à 21:11, Justin Lubin <notifications@github.com> a
écrit :
… For what it's worth, Sketch-n-Sketch still doesn't load on Chrome OS
version 62.0.3202.97 (64-bit).
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#84 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADbyt_e8FTqO2LDCYLzQetXgJBFT-vN_ks5tFanHgaJpZM4KAluQ>
.
|
Oof! I'm so silly, I didn't try it locally. It actually does work on Chrome OS now, thanks Mikaël / sorry to bother! :-) |
You're welcome !
Le ven. 29 déc. 2017 à 22:43, Justin Lubin <notifications@github.com> a
écrit :
… Oof! I'm so silly, I didn't try it locally. It actually *does* work on
Chrome OS now, thanks Mikaël / sorry to bother! :-)
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#84 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADbyt1yYq3zq_8VXj3KQSLP1zGe2PRUcks5tFb9mgaJpZM4KAluQ>
.
|
I consider this thread as closed. The following two links now work. https://ravichugh.github.io/sketch-n-sketch/releases/v0.6.2/ |
The elm-lang.org home page links to http://ravichugh.github.io/sketch-n-sketch/releases/latest/ which redirects to http://ravichugh.github.io/sketch-n-sketch/releases/v0.5.2/. The latter fails for me almost immediately with the error "Maximum call stack size exceeded" when I run it from Chrome (53.0.2785.116) on Mac OS X on a machine with 16GB RAM. When run from Firefox on the same machine it works, or at least starts up OK.
Ed. note: Duplicate of #56, #93.
The text was updated successfully, but these errors were encountered: