You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some C code generated through the CertiCoq project.
Emscripten produces a Wasm module that fails with a stack overflow/ memory access out of bounds runtime error when trying to run the module via the generated js scaffolding and nodejs (v.20.12.2).
The x86-64 binary runs without issues.
I have attached a zip containing the C files needed for running the emcc command: sm_gauss_nat.zip
Error message for command node --stack-size=1000000 sm_gauss_nat-opt_O0.js:
Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 100000)
/home/martin/Documents/sm_gauss_nat/sm_gauss_nat-opt_O0.js:132
throw ex;
^
RuntimeError: memory access out of bounds
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6659)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6bfb)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
at sm_gauss_nat-opt_O0.wasm.s_compile_uncurried_uncurried_known_119 (wasm://wasm/sm_gauss_nat-opt_O0.wasm-000c23d6:wasm-function[34]:0x6d3a)
Node.js v20.12.2
Adding optimization flags doesn't seem to help, and increasing the stack size seems to cause a segmentation fault for me when trying to run with node.
increasing the stack size seems to cause a segmentation fault for me when trying to run with node.
That should fix it, so that segfault needs to be looked into. Do you mean a segfault in node itself, or in the compiled code? What is the output you see?
Sorry for the late, late reply. Adding -O1 and specifying a large enough stack size and initial memory produces the correct result, so that's a mistake on my part.
As far as I can tell, the segfault arises from specifying a stack size that is too large when invoking node itself with --stack-size=X, e.g. with X=11000000 on my machine, but maybe that is intended/ the expected behavior with such a large size? (but this is something with node, not emscripten)
With no optimization flags, I can also increase the stack size and initial memory to the point where I don't get the stack overflow/ memory out of bounds errors, but the behavior differs, similar to this issue, so I will continue in that other issue.
For what it's worth, I tried compiling with both the undefined behavior sanitizer and the address sanitizer, but the binary that is produced with sanitizers has functions with too many locals (I also tried with the minimal runtime), and adding -sASSERTIONS=2 and -sSAFE_HEAP doesn't tell me anything.
I have some C code generated through the CertiCoq project.
Emscripten produces a Wasm module that fails with a stack overflow/ memory access out of bounds runtime error when trying to run the module via the generated js scaffolding and nodejs (v.20.12.2).
The x86-64 binary runs without issues.
I have attached a zip containing the C files needed for running the
emcc
command:sm_gauss_nat.zip
Error message for command
node --stack-size=1000000 sm_gauss_nat-opt_O0.js
:Adding optimization flags doesn't seem to help, and increasing the stack size seems to cause a segmentation fault for me when trying to run with node.
Emscripten Version
Full command:
Output:
The text was updated successfully, but these errors were encountered: