-
Notifications
You must be signed in to change notification settings - Fork 3.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
Segfault on combo of global ctors, ostream, wasi #11001
Comments
The the same binary work on wasmer and/or wasmtime? If so that would point to it being a node issue. If not then its more likely and emscripten issue and there is something wrong with the wasm file itself. |
When you say "segfault" do you mean in node.js's code itself, or in the compiled C code (so a wasm trap on out of bounds)? |
I think it should be a node problem, the segfault happens at node, here is the backtrace
I also did a hack to fallback to emscripten's import environment provided by the emcc(instead of using the wasi from nodejs) and it works fine. However I still curious to see what was going on here. Of course this issue can be closed since that may not be an emscripten issue, or it could also due to some incompatibility? I am also curious why iostream and ctor in particular triggers the problem, it would be great to get some of your thoughts, otherwise, please feel free to close the issue. Thank you! |
Oh, I see the problem. If you want to build portable wasm binaries you need to build with The node wasi implementation probably should be crashing though so you still might want to open a bug there. I think its crashing because the wasm module without STANDALONE_WASM does not export BTW does the crash happen even if you don't call GetX? How about if you don't even call _start? I imagine the crash is happening during _start? |
I managed to reproduce this crash against node 14, even with It looks like it happens with a simple hello world program too:
The result works under wasmer and wasmtime:
But crashes under node14+wasi:
|
Ok, definitely sounds like a node bug then. @tqchen please open an issue there if you haven't already, and link to it here, thanks! |
Nodejs issue nodejs/node#33175 |
Thanks @tqchen ! Btw it might be useful to attach the wasm file there, so it's easy for them to reproduce (that's what I'd prefer if I were them, I think, but I could be wrong). |
Thanks @kripken the issue is now confirmed in the nodejs repo and they have updated with a wasm file. |
Update: according to nodejs/node#33175 |
Ok that makes sense, and it sounds like they are going to fix the crash too. Se the bug was in the JS harness code, and nothing to do with emscripten?. Can we close this issue now? |
Dear developers. I encountered an interesting case when both global ctors need to be called, and ostream being used in the WASM standalone mode (emsdk latest upstream).
I have a case where I need to call the global static initializers(need to call _start before running other functions), but also have ostream in the code.
What was happening is that when ostream is being used in the code and it somehow triggers certain things to be added to global ctors, and then calling global ctors resulted in a segfault. So far I only get this error on node14, and I am not sure if it is related to the use of WASI.
C++
NodeJS
The text was updated successfully, but these errors were encountered: