Skip to content

runtime hang invoking thread with lambda function in side #16079

Closed

Description

@sps-gold

hangs during runtime if thread is invoked using lambda function in side module, with lambda function in side module too

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.1-git (1934a98e709b57d3592b8272d3f1264a72c089e4)
clang version 14.0.0 (https://github.com/llvm/llvm-project f142c45f1e494f8dbdcc1bcf14122d128ac8f3fe)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:

em++ side.cpp -o side.wasm -sSIDE_MODULE=2 -pthread -sPTHREAD_POOL_SIZE=1
em++ main.cpp -sMAIN_MODULE=2 side.wasm -sEXIT_RUNTIME -pthread -sPTHREAD_POOL_SIZE=1
node --experimental-wasm-threads a.out.js

Full link command and output with -v appended:

"/home/sps/Source/git/AutoCAD/emsdk-publisher/emsdk-main/upstream/bin/wasm-ld" -o side.wasm /home/sps/Learn/emsdk_op/emscripten_temp_rhtmrqsf/side_0.o -L/home/sps/Source/git/AutoCAD/emsdk-publisher/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic /home/sps/Source/git/AutoCAD/emsdk-publisher/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/crtbegin.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --import-memory --shared-memory --strip-debug --export-if-defined=main --export-if-defined=_emscripten_thread_init --export-if-defined=_emscripten_thread_exit --export-if-defined=emscripten_tls_init --export-if-defined=emscripten_current_thread_process_queued_calls --export-if-defined=pthread_self --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=fflush --export-if-defined=setThrew --export-if-defined=emscripten_stack_get_end --export-if-defined=emscripten_stack_get_free --export-if-defined=emscripten_stack_set_limits --export-if-defined=stackSave --export-if-defined=stackRestore --export-if-defined=stackAlloc --export-if-defined=__wasm_call_ctors --export-if-defined=__errno_location --export-if-defined=emscripten_dispatch_to_thread_ --export-if-defined=_emscripten_main_thread_futex --export-if-defined=_emscripten_thread_free_data --export-if-defined=_emscripten_allow_main_runtime_queued_calls --export-if-defined=emscripten_main_browser_thread_id --export-if-defined=emscripten_main_thread_process_queued_calls --export-if-defined=emscripten_run_in_main_runtime_thread_js --export-if-defined=emscripten_sync_run_in_main_thread_2 --export-if-defined=emscripten_sync_run_in_main_thread_4 --export-if-defined=memalign --export-if-defined=malloc --export-if-defined=free --experimental-pic -shared --no-export-dynamic

Result

hello from main
hello from side
try calling thread with fnptr
success
try calling thread with lambda
^C

Expected

hello from main
hello from side
try calling thread with fnptr
success
try calling thread with lambda
success

should not hang invoking thread using lambda function
proj.zip

Activity

  1. sps-gold commented on Jan 24, 2022

    @sps-gold
    ContributorAuthor

    update: that the lambda function needs to reside in side module too, to reproduce this hang

  2. self-assigned this
    on Mar 1, 2022
  3. sbc100 commented on Mar 1, 2022

    @sbc100
    Collaborator

    I think this issue may have been recently fixed. I tried repro it but it worked as expected:

    $ node --experimental-wasm-threads a.out.js
    hello from main
    hello from side
    try calling thread with fnptr
    success
    try calling thread with lambda
    success
    value from sidey = 0
    
  4. sbc100 commented on Mar 1, 2022

    @sbc100
    Collaborator

    I can confirm that this issue appears fixed in 3.1.4. I can repro at 3.1.3 but not in 3.1.4 and above!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions