emscripten-core / emscripten-core/emscripten

Dynamic Libraries: RuntimeError function signature mismatch

Open
#13,073 5 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hi!

Similar to my previous issues, here is another fairly simplified test case, which results in the following error during WASM instantiation:
```
Uncaught (in promise) RuntimeError: function signature mismatch
at _ZN8Standard8AllocateEm (:wasm-function[23]:0x1379)
at obj. (https://embind-dynamic-libs-03-git-master.donalffons.vercel.app/emscripten/build/main.js:2037:31)
at _ZN18Standard_TransientnwEm (:wasm-function[4]:0x200)
at :wasm-function[3]:0x1c8
at :wasm-function[5]:0x219
at __post_instantiate (:wasm-function[1]:0x1b6)
at callRuntimeCallbacks (https://embind-dynamic-libs-03-git-master.donalffons.vercel.app/emscripten/build/main.js:1747:11)
at initRuntime (https://embind-dynamic-libs-03-git-master.donalffons.vercel.app/emscripten/build/main.js:1361:3)
at doRun (https://embind-dynamic-libs-03-git-master.donalffons.vercel.app/emscripten/build/main.js:52650:5)
at run (https://embind-dynamic-libs-03-git-master.donalffons.vercel.app/emscripten/build/main.js:52672:5)
```
Repo: https://github.com/donalffons/embind-dynamicLibs-03
Live Example: https://embind-dynamic-libs-03-git-master.donalffons.vercel.app/javascript

- As before, the code is stripped down from a fairly large code base
- As before, there seems to be a race condition: Sometimes, WASM instantiation works as expected, sometimes it raises the error. For me, the web-hosted live examples runs without issues most of the time. On localhost, I see the error almost always.
- There is one MAIN_MODULE and 2 SIDE_MODULEs (named library1 and library2). Again, there is no Embind code.
- All what library2 does, is [`auto a = Standard::Allocate();`](https://github.com/donalffons/embind-dynamicLibs-03/blob/master/emscripten/library2.cxx#L3). This method is [implemented in library1](https://github.com/donalffons/embind-dynamicLibs-03/blob/master/emscripten/library1.cxx#L12):
```cpp
class Standard_MMgrRaw
{
public:
virtual void* Allocate() {
return new int;
}
};

void* Standard::Allocate()
{
std::cout << "1" << std::endl;
auto a = new Standard_MMgrRaw ();
std::cout << "2" << std::endl;
auto b = a->Allocate(); // RuntimeError: Function signature mismatch
std::cout << "3" << std::endl;
return b;
}
```

Full disclosure: This is most probably the same issue as #13026, but I was hoping to get your attention towards this test case with a new issue.

I would greatly appreciate help with this, as this is a major blocking point for my project.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.