Skip to content
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

PThreads unable to initialize on Firefox after 3.1.48 #23032

Open
wenhanchong opened this issue Nov 28, 2024 · 2 comments
Open

PThreads unable to initialize on Firefox after 3.1.48 #23032

wenhanchong opened this issue Nov 28, 2024 · 2 comments

Comments

@wenhanchong
Copy link

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.48-git (e967e20b4727956a30592165a3c1cde5c67fa0a8)
clang version 18.0.0 (https://github.com/llvm/llvm-project a54545ba6514802178cf7cf1c1dd9f7efbf3cde7)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/chongw/external/emsdk_temp/upstream/bin

Full link command and output with -v appended:

emcc: warning: -sMAIN_MODULE + pthreads is experimental [-Wexperimental]
 /home/chongw/external/emsdk_temp/upstream/bin/wasm-ld -o /home/chongw/misc/emscriptentest/build/index.wasm --whole-archive /tmp/emscripten_temp_wbk13kk2/main_0.o -L/home/chongw/external/emsdk_temp/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic /home/chongw/external/emsdk_temp/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/crtbegin.o /home/chongw/external/emsdk_temp/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/crt1_proxy_main.o -lc-mt-debug -lc++-mt-noexcept -lc++abi-debug-mt-noexcept -lGL-mt -lal -lhtml5 -lbulkmemory -lstubs-debug -lnoexit -ldlmalloc-mt -lcompiler_rt-mt -lsockets-mt --no-whole-archive -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export-if-defined=setThrew --export-if-defined=setTempRet0 --export-if-defined=malloc --export-if-defined=_emscripten_thread_init --export-if-defined=_emscripten_thread_free_data --export-if-defined=emscripten_stack_get_current --export-if-defined=_emscripten_thread_exit --export-if-defined=__errno_location --export-if-defined=htons --export-if-defined=ntohs --export-if-defined=memcpy --export-if-defined=free --export-if-defined=htonl --export-if-defined=_emscripten_timeout --export-if-defined=_emscripten_run_on_main_thread_js --export-if-defined=__cxa_is_pointer_type --export-if-defined=emscripten_stack_get_base --export-if-defined=emscripten_stack_get_end --export-if-defined=_emscripten_run_callback_on_thread --export-if-defined=__cxa_can_catch --export-if-defined=__cxa_increment_exception_refcount --export-if-defined=__cxa_decrement_exception_refcount --export-if-defined=fileno --export-if-defined=emscripten_builtin_memalign --export-if-defined=__dl_seterr --export-if-defined=memcmp --export-if-defined=pthread_self --export-if-defined=_emscripten_proxy_dlsync_async --export-if-defined=_emscripten_proxy_dlsync /tmp/tmppohd0ovplibemscripten_js_symbols.so --import-memory --shared-memory --export-dynamic --export-if-defined=main --export-if-defined=_emscripten_thread_init --export-if-defined=_emscripten_thread_exit --export-if-defined=_emscripten_thread_crashed --export-if-defined=_emscripten_tls_init --export-if-defined=pthread_self --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=__wasm_apply_data_relocs --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_set_limits --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=_emscripten_thread_free_data --export=emscripten_main_runtime_thread_id --export=emscripten_main_thread_process_queued_calls --export=_emscripten_run_on_main_thread_js --export=_emscripten_dlsync_self --export=_emscripten_dlsync_self_async --export=_emscripten_proxy_dlsync --export=_emscripten_proxy_dlsync_async --export=__dl_seterr --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export=setThrew --export=setTempRet0 --export=malloc --export=_emscripten_thread_init --export=_emscripten_thread_exit --experimental-pic -pie -z stack-size=65536 --initial-memory=16777216 --max-memory=16777216 --entry=_emscripten_proxy_main --stack-first
 /home/chongw/external/emsdk_temp/upstream/bin/llvm-objcopy /home/chongw/misc/emscriptentest/build/index.wasm /home/chongw/misc/emscriptentest/build/index.wasm --remove-section=.debug* --remove-section=producers
 /home/chongw/external/emsdk_temp/upstream/bin/wasm-emscripten-finalize -g --dyncalls-i64 --pass-arg=legalize-js-interface-export-originals --pass-arg=legalize-js-interface-exported-helpers /home/chongw/misc/emscriptentest/build/index.wasm -o /home/chongw/misc/emscriptentest/build/index.wasm --detect-features
 /home/chongw/external/emsdk_temp/node/20.18.0_64bit/bin/node /home/chongw/external/emsdk_temp/upstream/emscripten/src/compiler.js /tmp/tmpnmvup7t5.json
 /home/chongw/external/emsdk_temp/node/20.18.0_64bit/bin/node /home/chongw/external/emsdk_temp/upstream/emscripten/tools/preprocessor.js /tmp/emscripten_temp_wbk13kk2/settings.js worker.js --expandMacros
 /home/chongw/external/emsdk_temp/node/20.18.0_64bit/bin/node /home/chongw/external/emsdk_temp/upstream/emscripten/tools/preprocessor.js /tmp/emscripten_temp_wbk13kk2/settings.js shell.html

PThreads does not initialize on Firefox after this particular change: #20404
There are no errors logged in the console. Attached a sample app that can reproduce the issue. Tested on Firefox 133 windows desktop. Works fine on Chrome 131.

emscriptentest.zip

@kripken
Copy link
Member

kripken commented Dec 2, 2024

What do you mean by "pthreads unable to initialize"? Does pthread_create error, or just nothing happens at all? Does the Firefox debugger show Workers being created?

Overall this sounds like a Firefox bug, but it is odd that it is caused by a change that is ok in other browsers.

@shinji-TH
Copy link
Contributor

I tried running the package with the same Emscripten version.
seems like the pthread_create did not flag out any error on the console, when main function get invoke on the worker threads, nothing happens at all
image

In regular chrome browser, the main function get invoked and started
image

Removing the flag -sPROXY_TO_PTHREADS does allow the code to run normally on firefox
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants