wabt
wabt copied to clipboard
Make online wat2wasm respect the enable exception flag
Tried https://webassembly.github.io/wabt/demo/wat2wasm/ feeding in some simple Wat with exception definitions:
I do not get the errors if I run the tool manually.
It does not seems trivial. It seems the exceptions boolean is written into some p array, which is probably an (emscripten) emulated memory. If I read it back with Module["_wabt_exceptions_enabled"](5626592) (the number seems an address passed to Module["_wabt_set_exceptions_enabled"]) I got 1. Unfortunately there is a lot of generated code here and hard to debug its intention.
I thought it more likely an issue in the code that calls "generic" wat2wasm/. Because if you manually call the tool from the command line with exceptions enabled flag you do not get an error.
There is a lot happening here. The online code is generated from the C source code, and the generator creates some bridge between the js world and the C world. I can confirm that the bridge reads the "exceptions" flag correctly, and store it as value 1 in some internal array called p. I suspect it is a memory like interface, since the location is called addr. I am sure the intention is to use this value later, but it does not happen (or an incorrect address is used), and it is hard to debug because the code is generated.
It looks like the web version just needs to be updated. I rebuilt it locally and your example worked for me!
https://github.com/WebAssembly/wabt/pull/1907
The online wat2wasm demo now seems to unconditionally allow exceptions whether the box is checked or not...
I noticed that too, I think there may be a few places where the exceptions flag isn't properly checked.
We seem to have a (different) bug where a tag element is allowed even without --enable-exceptions, but this isn't particular to the online wat2wasm. Closing this issue.