-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Failed to load shared library #17601
Comments
Can you confirm its still broken with Its hard to tell what it might be without more info. Does the Error come with stack trace perhaps? Does it reproduce in an |
Thanks for your suggestions! It helped me to find out that in my main program some exports are missing which are needed in my plugin.... Do you know a clean and automatic way to ensure all exports from the main program are created without recording the plugin in the dylink section? |
Yes you can pass the library when linking the main program and then add |
Ah nice! Seems to be a global flag which means there is no grouping, nevertheless it's much easier to keep track of library deps instead of functions which need to be present.... Thanks! |
Unfortunately the missing exports had nothing to do with my problem (this only showed up due to missing DCE with -O0). I debugged a bit further and the call stack is: In the invoke_vii we get a valid wasm table entry. The call getWasmTableEntry(index)(a1,a2); leads immediately to a function signature mismatch. From the stacktrace it seems that __dynamic_cast produces this function signature mismatch... |
Can you produce at How are you loading your library? dlopen? Is this happening during the dlopen call? |
Does it happen with |
I can reproduce it on the latest tot build with -sSIDE_MODULE=1 -O2 and with -sASSERTIONS=2 enabled when I'm opening the library with dlopen. I try to create a reduced test case. |
While trying to create the small test case I encounter a wasm-ld crash with the following stacktrace: /build/emsdk/upstream/emscripten/em++ -O2 -g -o /build/libXXX.wasm /build/XXX/wasm_32/install/lib/libXXX.a -fexceptions -s SIDE_MODULE=1 -s DISABLE_EXCEPTION_CATCHING=0 Which means I'm kind of stuck as I've no idea if this is somehow related or is an independent wasm-ld bug. |
@sbc100: Thanks for your help. It seems that when dlopening a shared library __wasm_call_ctors is called without a preceding call to __wasm_apply_data_relocs: emscripten/src/library_dylink.js Lines 651 to 667 in 90139f8
Swapping and calling __wasm_apply_data_relocs before __wasm_call_ctors fixes the crash. Nevertheless I'm not sure if this is the right fix... |
Hi, Pyodide team is also suffering this error, and retrying |
Indeed that certainly looks like the wrong order to me. I wonder how that isn't covered by our tests .. I guess that more of our tests are using load time dynamic linking. Notice that when the library are loaded before the runtime is initialized then they are run in the other (correct) order: Lines 266 to 270 in 2b2e142
|
This bug applied to libraries loaded after the runtime initialized. Fixes: #17601
This bug applied to libraries loaded after the runtime initialized. Fixes: #17601
This bug applied to libraries loaded after the runtime initialized. Fixes: #17601
This bug applied to libraries loaded after the runtime initialized. Fixes: #17601
Please include the following in your bug report:
I recently updated my emscripten version and now get: "Error in loading dynamic library libXXX.wasm: RuntimeError: null function or function signature mismatch".
Bisecting found that since llvm-roll https://chromium.googlesource.com/emscripten-releases/+/c3f55f5c179c073c569684a0640727edb7c5d10e the loading is broken (somewhere between 3.1.14 and 3.1.15).
@sbc100: Do you have an idea if this could be related somehow to not applying data relocations at static constructor time?
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.15-git (ae675c6)
clang version 15.0.0 (https://github.com/llvm/llvm-project 9f94d63a6a7e00a792fb0e05dbb5ad08313ec9bc)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /build/emsdk/upstream/bin
Full link command and output with
-v
appended:em++ -O3 -o libXXX.wasm static_library1.a static_library2.a -fexceptions -fPIC -s SIDE_MODULE=2 -s DISABLE_EXCEPTION_CATCHING=0 -s "EXPORTED_FUNCTIONS=['_custom_function1','_custom_function1']"
Any help would be appreciated! Thanks in advance!
The text was updated successfully, but these errors were encountered: