-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.7-git (a53b1a34f0b31f05f2045f2d4aa1343f75180693)
Copyright (C) 2025 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Failing command line in full:
em++ ./main.cpp -o main.js -fwasm-exceptions -sEXPORT_EXCEPTION_HANDLING_HELPERS=1
(Any C++ source file will work.)
This outputs a main.js where getExceptionMessage is in unexportedSymbols due to the implicit -sASSERTIONS=1. Importing main.js always causes an error since ASSERTIONS overrides the getter of anything in unexportedSymbols to throw an error:
Line 531 in c2d94c8
| // in ASSERTIONS mode we show a useful error if it is used without being |
The test in test_core.py, however, explicitly disables ASSERTIONS:
Line 1380 in c2d94c8
| self.set_setting('ASSERTIONS', 0) |
I don't think disabling ASSERTIONS should be required to use exception helpers? If it needs to be, then you can probably dismiss this.
This stems from
Line 1839 in c2d94c8
| settings.EXPORTED_FUNCTIONS += ['getExceptionMessage', 'incrementExceptionRefcount', 'decrementExceptionRefcount'] |
EXPORTED_FUNCTIONS instead of EXPORTED_RUNTIME_METHODS, and changing this lets me import the file.
However, now getExceptionMessage with ASSERTIONS and Emscripten exceptions somehow triggers a WebAssembly.RuntimeError for memory access out of bounds. The __get_exception_message in system/lib/libcxxabi/src/cxa_exception_js_utils.cpp used from src/lib/libcore.js apparently dies while returning. I have no idea when this error is emitted or how ASSERTIONS could impact that.
Please let me know if I'm missing anything. Thanks for reading.