Commit 9818015
committed
finding 2: use JS-provided throw_or_abort_impl for WASM error recovery
In WASM builds, BB_NO_EXCEPTIONS is defined. The C++ definition of
throw_or_abort_impl calls std::abort(), killing the WASM process on
any error. Meanwhile, the header declares it as WASM_IMPORT from JS,
where it throws a catchable Error. But the local C++ definition
shadows the import.
Fix: guard out the C++ definition with #ifndef __wasm__ so the JS
import is used in WASM builds. For wasmtime (non-JS WASM runtime
used in CI tests), add -Wunknown-imports-trap=y so the import is
stubbed with a trap (correct behavior: errors in wasmtime should
still abort).
Before: any throw_or_abort in WASM kills the process, PXE crashes.
After: the JS caller gets a catchable Error("actual error message").1 parent e882aec commit 9818015
2 files changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
1 | 12 | | |
2 | 13 | | |
3 | 14 | | |
| |||
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
| 41 | + | |
| 42 | + | |
0 commit comments