wabt icon indicating copy to clipboard operation
wabt copied to clipboard

Make online wat2wasm respect the enable exception flag

Open hamishwillee opened this issue 3 years ago • 7 comments

Tried https://webassembly.github.io/wabt/demo/wat2wasm/ feeding in some simple Wat with exception definitions: image I do not get the errors if I run the tool manually.

hamishwillee avatar Apr 25 '22 06:04 hamishwillee

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.

zherczeg avatar Apr 25 '22 08:04 zherczeg

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.

hamishwillee avatar Apr 25 '22 23:04 hamishwillee

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.

zherczeg avatar Apr 26 '22 05:04 zherczeg

It looks like the web version just needs to be updated. I rebuilt it locally and your example worked for me!

binji avatar Apr 26 '22 06:04 binji

https://github.com/WebAssembly/wabt/pull/1907

binji avatar Apr 26 '22 06:04 binji

The online wat2wasm demo now seems to unconditionally allow exceptions whether the box is checked or not...

keithw avatar May 18 '22 01:05 keithw

I noticed that too, I think there may be a few places where the exceptions flag isn't properly checked.

binji avatar May 18 '22 17:05 binji

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.

keithw avatar Dec 23 '22 04:12 keithw