-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.19 (a5f7b1c)
clang version 16.0.0 (https://github.com/llvm/llvm-project 30171e76f0e5ea8037bc4d1450dd3e12af4d9938)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/user/emscripten/emsdk_tot/emsdk/upstream/bin
When I'm opening a library through dlopen an assert in dynCallLegacy is triggered and a RuntimeError: Aborted(Assertion failed: bad function pointer type - no table for sig 'ji') is thrown.
Dynamically linking the library works as expected.
Test case that triggers the behavior:
Side library: side.cpp
Build with:
em++ -Wall -g -O0 -sDISABLE_EXCEPTION_CATCHING=0 -sSIDE_MODULE=1 side.cpp -o libside.wasm
#include <stdint.h>
extern "C" {
typedef int64_t (*i64Fn)();
int64_t calc(i64Fn f) { return f(); }
int64_t callI64(i64Fn f) {
try {
return calc(f);
} catch (...) {
return calc(f);
}
}
}Main: main_dlopen.cpp
Build with:
em++ -g -sDISABLE_EXCEPTION_CATCHING=0 -s MAIN_MODULE=2 main_dlopen.cpp -sDYLINK_DEBUG=1 -o main_dlopen.js -sASSERTIONS=2 -sEXPORTED_FUNCTIONS=[_main] -sNO_AUTOLOAD_DYLIBS libside.wasm
#include <stdint.h>
#include <dlfcn.h>
typedef int64_t (*i64Fn)();
typedef int64_t (*fun_ptr_type_callI64)(i64Fn);
int64_t return_main() { return -1; }
int main() {
void * handle = dlopen("libside.wasm", RTLD_NOW);
fun_ptr_type_callI64 get_function_ptr = ( fun_ptr_type_callI64 )dlsym(handle, "callI64");
get_function_ptr(return_main);
return 0;
}