emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.79k stars 3.3k forks source link

Assertion base > stack_size / 2 failed located in the calculate_stealing_threshold function #22379

Open Alexufo opened 2 months ago

Alexufo commented 2 months ago

version: 3.1.56, 3.1.60

Code without threads works fine, but on multithreads i got

wasm.js:3690 Assertion base > stack_size / 2 failed (located in the calculate_stealing_threshold function, line in file: 572)

image

And part in js from emscripten

image

I have a debug mode. In release mode, the error doesn't seem to occur

add_link_options(--bind -sWASM -sNO_EXIT_RUNTIME)
add_link_options(--no-entry)

add_link_options(--closure=1)

add_link_options(-sMODULARIZE)

add_link_options(-sENVIRONMENT=web,worker)

add_link_options(-sNO_FILESYSTEM)
add_link_options(-sNO_USE_SDL -sNO_USE_SDL_MIXER)
add_link_options(-sALLOW_MEMORY_GROWTH=1)

add_link_options(-sMINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION=1)
add_link_options(-sDYNAMIC_EXECUTION=1)

add_link_options(-sNO_HTML5_SUPPORT_DEFERRING_USER_SENSITIVE_REQUESTS)
add_link_options(-sNO_ABORT_ON_WASM_EXCEPTIONS)
add_link_options(-sEXPORTED_FUNCTIONS=_malloc,_free)

add_link_options(-sINCOMING_MODULE_JS_API=['locateFile','mainScriptUrlOrBlob','instantiateWasm','buffer'])

add_link_options(-sNO_ERROR_ON_UNDEFINED_SYMBOLS)

 add_compile_options(-pthread)
 add_compile_options(-sSHARED_MEMORY=1)
 add_link_options(-pthread)
 add_link_options(-sPTHREAD_POOL_SIZE=4)
 add_link_options(-sSHARED_MEMORY=1)

if(CMAKE_BUILD_TYPE EQUAL debug)
  add_link_options(-sASSERTIONS=1)

  add_link_options(-sDISABLE_EXCEPTION_CATCHING=0)
  add_compile_options(-sDISABLE_EXCEPTION_CATCHING=0)

  add_link_options(-sEXPORT_EXCEPTION_HANDLING_HELPERS=1)
  add_link_options(-sEXCEPTION_STACK_TRACES=1)
  add_link_options(-fexceptions)
endif()
sbc100 commented 2 months ago

Do you know where calculate_stealing_threshold is defined so what its trying to do? It don't think its part of emscripten itself.

Does increasing the stack size help? I.e. does building with -sSTACK_SIZE=16mb make the problem go away?

Alexufo commented 1 month ago

calculate_stealing_threshold - from tbb lib

thank you. Yes it helped.

What is the danger of a large stack? Can it impose a restriction on something?