aWsm
aWsm copied to clipboard
Improve "Trap Handling" for out of bounds memory access and other traps
According to the WebAssembly specification, abnormal behavior, such as an out-of-bounds memory access, should trigger a "trap."
Source:
In the web context, this causes a JavaScript exception. However, the WebAssembly specification is being extended to support "in module" trap handlers (https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md)
Currently, we are mostly enforcing invariants via assert
. We should likely replace this with a centralized entrypoint for trap handling logic called via setjmp and longjmp. I believe this would just log a descriptive and error out for now.