emscripten-core / emscripten-core/emscripten
dlopen returns incorrectly on subsequent load
- 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.53 (ce5114bdd2175c7297583d3c25a53ca95d22f4ce)
**Failing command line in full:**
emcc main.cpp -s MAIN_MODULE=2 --preload-file %output_path%/side.wasm@side.wasm -o %output_path%\index.html -s ASSERTIONS=0
**Full link command and output with `-v` appended:**
Even for runtime issues it helps a lot if you can include the full link command.
Adding `-v` to the link command will show all of the sub-commands run which
can help us diagnose your issue.
Issue:
After loading a corrupted side module the first time, if we happen to load that side module a second time again, it will succeed this time.
This is not expected.
main.cpp
```cpp
int main()
{
printf(" ********* Test load side module ********* \n");
auto handle = dlopen("side.wasm", RTLD_LAZY | RTLD_GLOBAL);
if (handle == nullptr) {
printf("1st load fail: %s\n", dlerror());
}
handle = dlopen("side.wasm", RTLD_LAZY | RTLD_GLOBAL);
if (handle == nullptr) {
printf("2nd load fail: %s\n", dlerror());
return -1;
}
printf("2nd load SUCCESS??\n");
return 0;
}
```
Result:

Contributor guide
Assessment
This issue has not been assessed yet.