-
Notifications
You must be signed in to change notification settings - Fork 0
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
Crash Encountered With Emscripten 1.36.3 #1
Comments
Very interesting, the rust issue appears to be this line: I'm 99% sure I know what the issue is (a very deeply nested set of asm.js statements means that the naive freeing mechanism overflows the stack when attempting to recurse and free everything) so I'll fix that and get back to you. |
Thanks, do you know if there is a quick way for me to identify the particular set of asm.js statements that is causing the problem? The reason why I would like to do this is because I see the 'callstack size exceeded' problem on Chrome and I would like to know the code path that triggers this problem. |
Interesting! The ayzim problem will be because of an incredibly deeply nested expression/set of conditionals in a function, and I assumed that a 'callstack size exceeded' would be due to recursion. But I've just checked, and a deeply nested expression in a single function with no recursion can also cause it (code example at bottom) so they probably are the same problem! I think omitting the eliminate pass would help (comment out I'll have a think about a way to identify a deep nesting. I think it should be relatively easy to add a small trace in ayzim to give you some information once I've fixed the recursive destructor. Generate nonrecursive js to cause callstack size exceeded:
|
I'm curious, why is deep nesting worse here (rust/ayzim vs c++/old optimizer)? |
The old optimizer doesn't actually free memory, it just leaks it. So given something like In general there isn't huge amounts of freeing...except at program exit, when everything must go! So I could probably fix this the lazy way by adding a process exit just before the end of main. |
But the old optimizer will still recurse those nodes, not to free them, but to do all the other stuff it does? Why is freeing special here? |
There's very little recursion in the old optimizer, courtesy of the |
Oh right, thanks, I forgot we de-recursed traversal in C++. I had the earlier JS version in mind which is recursive. |
Ok, I found a couple more places that recurse (parsing and emitting output) both in ayzim and the emscripten optimizer. But it appears the emscripten optimizer has a workaround for stack size problems on Windows! @awtcode I'd like to get to the bottom of this and waste as little of your time as possible, so I've built a new binary: https://aidanhs.com/ayzim-opt-awtcode.exe
The line saying If anything jumps out, you can use DEAD_FUNCTIONS to kill suspiciously large functions and see if that helps Chrome at least parse your JS. If you get a chance at some point to take a look at any of the above I'd be very interested to hear back. It'd be easy to extend the reporting to be on every function (rather than one per chunk, which I just did to stop it being overwhelming), so let me know if you have any thoughts on something that you might find helpful. |
Thanks @aidanhs , will try it out and let you know the results asap :) |
Hi, I reran my code with the new binary and this is what I saw: starting reading and parsing This seems to be a new error though. |
Hmm, that's unexpected. Your file clearly has something non-utf8 in it. I didn't think non-ascii asm.js would be generated, let alone non-utf8, so clearly I need to examine these assumptions. It could be something withing the generated asm.js itself, or something to do with encoding on windows. Do you have anything non-ascii in your program at all? Function names, variables, strings? Alternatively, do you use non-default-US encoding on Windows? As a compounding bit of confusion, it's actually not even getting as far as it was last time! The place this error comes from is before anywhere the stack could have possibly overflowed, so either something changed on the machine ayzim is being run on, me rebuilding ayzim on a different machine had adverse effects, or the Rust updates and dependency updates had adverse effects. Just to double check I'm correct in my assumption in where this is coming from, could you run with |
Hi,
I tried using the optimizer and saw a crash in Emscripten 1.36.3. Here's part of the error log:
thread 'main' has overflowed its stack
DEBUG:root:EMCC_WASM_BACKEND tells us to use asm.js backend
splitting up js optimization into 124 chunks, using 40 cores (total: 301.94 MB)
Traceback (most recent call last):
File "E:\emsdk\emscripten\1.36.3\em++", line 13, in
File "E:\emsdk\emscripten\1.36.3\emcc.py", line 1731, in run
File "E:\emsdk\emscripten\1.36.3\emcc.py", line 1643, in flush
File "E:\emsdk\emscripten\1.36.3\emcc.py", line 1613, in run_passes
File "E:\emsdk\emscripten\1.36.3\tools\shared.py", line 1741, in js_optimizer
File "E:\emsdk\emscripten\1.36.3\tools\js_optimizer.py", line 544, in run
File "E:\emsdk\emscripten\1.36.3\tools\tempfiles.py", line 64, in run_and_clean
File "E:\emsdk\emscripten\1.36.3\tools\js_optimizer.py", line 544, in
File "E:\emsdk\emscripten\1.36.3\tools\js_optimizer.py", line 446, in run_on_js
File "E:\emsdk\python\2.7.5.3_64bit\lib\multiprocessing\pool.py", line 250, in map
File "E:\emsdk\python\2.7.5.3_64bit\lib\multiprocessing\pool.py", line 557, in get
AssertionError: Error in optimizer (return code 255):
ninja: build stopped: subcommand failed.
The text was updated successfully, but these errors were encountered: