-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Failed assertion in asm2wasm when using Asyncify and setjmp #5383
Comments
That does look like the issue. The asyncify pass moves some code out of main, and then it can't find those local vars. And I think it's a fundamental issue, since we need those setjmp helper vars in order to handle setjmp properly. In other words, it looks like asyncify is not compatible with setjmp, if asyncify rewrites a function using setjmp. |
I suppose that the stack was never really unwound at run-time in any of my |
I have exactly the same issue during compiling my Rust binary app:
using |
Strictly speaking, it is probably some other codegen issue resulting in the same assertion triggered in |
Yeah, probably a different issue that happens to hit a similar error. @afshinm, do you have an example input showing the issue? |
@kripken yeah, what I'm doing is compiling this public repo: https://github.com/afshinm/juggernaut/tree/master/example/juggernaut-demo using this command:
and I noticed if I remove |
Can you get the input files to emcc, and the emcc command that is run? (I don't have rust installed, and I don't understand how cargo works, so it would be very hard for me to get started debugging that.) |
@afshinm On Linux, in case nothing else helps you can easily monitor |
I hate to say this but after upgrading Rust to 1.19, the problem is gone: https://blog.rust-lang.org/2017/07/20/Rust-1.19.html Thanks for your reply guys and sorry for not being able to help you. |
Meanwhile, when I looked at Firefox console when running code with
When I manually added the lines var _setjmpTable = 0;
var _setjmpTableSize = 0; after var asm = (function(global,env,buffer) {
'use asm'; It was validated successfully. I suppose that this did not interfered with actual execution of the program: if these variables were referenced without these lines before, it should cause fatal error, right? After that instead of 20s load time on every load I got 25s on the first load and 3-5s on subsequent (with the same cached compiled code). Though, compiled version executed even 1.5-2x slower. I don't know why: maybe it is because of huge code base (99Mb js file with Maybe this kludge can be used to enable WASM builds of code using |
If they were read it would fail, but if written it would create a new global variable. I think that's what happens when those are missing. Then it seems to work, but of course it's wrong to put those in the global scope. Definitely a bug that those vars aren't being emitted properly. |
This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
Under some conditions, compilation of code using
setjmp
/longjmp
with Asyncify enabled causesasm2wasm
to crash on failed assertion.How to reproduce
Compile the following code
with
emcc test.c -o test.js -s WASM=1 -s ASYNCIFY=1
(see note about version).Expected: compiled successfully.
Actual: compilation fails with the following error:
When compiled with
EMCC_DEBUG=2
, it looks like the function_main__async_cb
references_setjmpTable
but does not declares it, unlike the_main
function that does declare it. If I swap thelongjmp
andemscripten_sleep
invocations, then it compiles successfully.I use Emscripten 1.37.15 with the patch from emscripten-core/emscripten-fastcomp#167
The text was updated successfully, but these errors were encountered: