emscripten-core / emscripten-core/emscripten
embind cannot be initialized correctly in a thread created in static constructor
Open
embind
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I found this bug because I created a thread in `wasmfs_before_preload()`, which has `__attribute__((init_priority(100)))`.
When the thread runs, embind has not been fully initialized in main thread. So `Module['__embind_initialize_bindings']` did not register the types for me, but set `initializedJS` to true.
I did not use embind in thread created in `wasmfs_before_preload`, but the worker is reused in another thread, and in that thread embind does not work, caused a crash in my app.
I hope we can have a way to ensure `wasm_init_ctors` are completed, or embind inited, when `spawnthread` get called.
Contributor guide
Assessment
This issue has not been assessed yet.