emscripten-core / emscripten-core/emscripten
ASYNCIFY_DEBUG causes stack overflow for empty program
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Create an empty C++ module and create an ES6 module.
Compile options for target Dummy: -fexceptions;-pthread;-matomics;-mbulk-memory;-msimd128;-O0;-g3
Compile definitions for target Dummy: COMPILE_DEFINITIONS-NOTFOUND
Include directories for target Dummy: INCLUDE_DIRECTORIES-NOTFOUND
Link libraries for target Dummy: Threads::Threads
Link options for target Dummy: -sASSERTIONS=2;-sERROR_ON_UNDEFINED_SYMBOLS=1;-sDISABLE_EXCEPTION_CATCHING=0;-sALLOW_BLOCKING_ON_MAIN_THREAD=0;-lembind;-sNO_EXIT_RUNTIME=1;-sMODULARIZE=1;-sEXPORT_ES6=1;-sINCLUDE_FULL_LIBRARY;-sALLOW_TABLE_GROWTH=1;-sEXPORT_NAME=loadDummyTestModule;-sINITIAL_MEMORY=1GB;-sALLOW_MEMORY_GROWTH=0;-sENVIRONMENT=node,worker;-pthread;-flto;--enable-bulk-memory;-sUSE_PTHREADS=1;-sSTACK_SIZE=1048576;-sPTHREAD_POOL_SIZE=2;-sPTHREAD_POOL_SIZE_STRICT=16;-sSHARED_MEMORY=1;-sWASM=1;-sASYNCIFY_STACK_SIZE=81920;-sASYNCIFY=1;-sASYNCIFY_DEBUG=2;-sEXPORTED_RUNTIME_METHODS=['ENV','FS','addFunction','removeFunction','wasmTable','ccall','cwrap','stringToNewUTF8','spawnThread'];-sEXPORTED_FUNCTIONS=['_free','_malloc'];-sASYNCIFY_IMPORTS=[];-O0;-g3
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/jmh/git/vtkEmbinding/build
[ 0%] Built target Dummy_copy_run_Dummy.js
[100%] Linking CXX executable Dummy.js
error: library_async.js: failure to execute js library "library_async.js":
error: library_async.js: use -sVERBOSE to see more details
Internal compiler error in src/compiler.mjs!
Please create a bug report at https://github.com/emscripten-core/emscripten/issues/
with a log of the build and the input files used to run. Exception message: "library_async.preprocessed.js:73
dbg(`ASYNCIFY: ${' '.repeat(Asyncify.exportCallStack.length} try ${x}`);
^^^^^^
SyntaxError: missing ) after argument list
at new Script (node:vm:117:7)
at createScript (node:vm:269:10)
at Module.runInContext (node:vm:300:10)
at runInMacroContext (file:///home/jmh/github/emsdk/upstream/emscripten/src/utility.mjs:333:13)
at Object.load (file:///home/jmh/github/emsdk/upstream/emscripten/src/modules.mjs:248:9)
at Module.runJSify (file:///home/jmh/github/emsdk/upstream/emscripten/src/jsifier.mjs:169:18)
at file:///home/jmh/github/emsdk/upstream/emscripten/src/compiler.mjs:89:11
em++: error: '/home/jmh/github/emsdk/node/20.18.0_64bit/bin/node /home/jmh/github/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpj8etiry9.json --symbols-only' failed (returned 1)
I discovered another issue. The generated code..
```
debugInit() {
function pthreadLogPrefix() {
var t = 0;
if (runtimeInitialized && typeof _pthread_self != 'undefined'
) {
t = _pthread_self();
}
return `w:${workerID},t:${ptrToString(t)}: `;
}
// Prefix all err()/dbg() messages with the calling thread ID.
var origDbg = dbg;
dbg = (...args) => origDbg(pthreadLogPrefix() + args.join(' '));
},
```
Causes a stack overflow during the early initialization. I patched the generated code and removed `dbg` and reinserted after the module was fully initialize. The issue only occurs if you use `-sASYNCIFY_DEBUG`.
I use the latest release 3.1.74
Thanks in advance
Contributor guide
Assessment
This issue has not been assessed yet.