Skip to content

How does the wasm-opt ensure the generated Wasm is valid and free from undefined behaviors? #7218

Answered by kripken
Shawdox asked this question in Q&A
Discussion options

You must be logged in to vote

The wasm file is a valid wasm file, in the sense that it validates in Binaryen, and should validate in all wasm VMs, unless we have a bug (please report it, if so).

Wasm itself does not have undefined behavior. The closest is nondeterminism in NaNs. The fuzzer does have some logic to handle that, it can do a "de-NaN" operation (search for NAN in scripts/fuzz_opt.py) to avoid NaNs at runtime, making the output fully deterministic.

(Other issues exist like infinite loops which are not undefined behavior, but can be a problem when fuzzing. The fuzzer also has logic to prevent that, see addHangLimitChecks().)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Shawdox
Comment options

@kripken
Comment options

Answer selected by Shawdox
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants