emscripten-core / emscripten-core/emscripten
dlopen - missing dynCall_ji in Module
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
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 (a5f7b1c9a1c74a830bebedc122d204800ce8dff9)
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`
```c++
#include
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`
```c++
#include
#include
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;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.