wasm-tools
wasm-tools copied to clipboard
wasm-smith: add a "no trapping" mode
I think we could do this with a post-processing pass, similar to what we do with ensure_termination.
We'd walk over each instruction and potentially insert some code right before it:
- We would insert a couple instructions to ensure that a division instruction's denominator is never zero
- We would insert a couple instructions to mask heap addresses to ensure they are within the memory's minimum size
- Similar for
table.getandtable.set - Similar for trapping floating point conversion instructions
- Every
unreachablewould be replaced with code to create dummy result values (ie zeroes) and thenbrout of the current control frame
We would also have to make sure that active data/elem segments were always in bounds of their memories/tables.
I think that's everything? I might be missing some trapping cases, but I think the approach would work for everything.
cc @alexcrichton