emscripten-core / emscripten-core/emscripten
[asyncify]: asyncify_stop_unwind throws a RuntimeError: unreachable
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Hi,
I am hitting an abort() when maybeStopUnwind is called after I refactored a pthread_create wrapper that [sets and cancels the mainloop](https://code.videolan.org/b1ue/vlc/-/commit/08c0fe66b51b2a54b143b079e72674c8f0d5e792) (to allow correctly joining the thread as a workaround to #17552).
Replacing the abort in [runAndAbortIfError](https://github.com/emscripten-core/emscripten/blob/77da62969eb0b5efe4ce4a0c9ce67c45b9e32638/src/library_async.js#L216) with a console.error to get the exception I get this trace :
```
RuntimeError: unreachable
at asyncify_stop_unwind (experimental.wasm:0x35470b3)
at ret. (experimental.js:7561:35)
at experimental.js:1152:22
at runAndAbortIfError (experimental.js:7449:16)
at Object.maybeStopUnwind (experimental.js:7584:11)
at ret. (experimental.js:7566:30)
at Object.doRewind (experimental.js:7628:16)
at experimental.js:7661:47
runAndAbortIfError @ experimental.js:7451
maybeStopUnwind @ experimental.js:7584
ret. @ experimental.js:7566
doRewind @ experimental.js:7628
(anonymous) @ experimental.js:7661
Promise.then (async)
(anonymous) @ experimental.js:7721
handleSleep @ experimental.js:7639
handleAsync @ experimental.js:7719
__asyncjs__init_js_file @ experimental.js:1360
imports. @ experimental.js:7527
$EmFileOpen @ experimental.wasm:0x45dd42
$generic_start @ experimental.wasm:0x31c049c
$vlc_module_load @ experimental.wasm:0x31bfcfa
$module_need @ experimental.wasm:0x31c0194
$access_New @ experimental.wasm:0x3279fa4
...
```
Sorry for not being able to provide a short sample, I tried fiddling with the one in #17552 but could not reproduce.
asyncify_stop_unwind is called regularly, and when it is called after [this function](https://code.videolan.org/b1ue/vlc/-/commit/49f585a2a5fbbc04d85fbccbf63881d2a659cc54#2a7dea5d33617957668666b0ac9a19b12f8b718c_0_138) or [this function](https://code.videolan.org/b1ue/vlc/-/blob/394a123418b39a827467598bf19aef7d9e0a3c3c/modules/codec/webcodec.cpp#L131), I am having [this](https://github.com/emscripten-core/emscripten/blob/77da62969eb0b5efe4ce4a0c9ce67c45b9e32638/src/library_async.js#L18) abort().
**Version of emscripten/emsdk:**
```
$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.17 (fbc532773d84d2bd7da876275671970e792ad1cd)
clang version 15.0.0 (https://github.com/llvm/llvm-project 17e4c217b66305e60657a48f10fe3c428c2fe4d2)
Target: wasm32-unknown-emscripten
```
Contributor guide
Assessment
This issue has not been assessed yet.