Skip to content

wasm: complete W4 (float execution + malformed-module robustness suite) - #162

Merged
jamiesun merged 1 commit into
mainfrom
wasm-w4-float-and-robustness
Jun 27, 2026
Merged

wasm: complete W4 (float execution + malformed-module robustness suite)#162
jamiesun merged 1 commit into
mainfrom
wasm-w4-float-and-robustness

Conversation

@jamiesun

Copy link
Copy Markdown
Collaborator

Completes the W4 phase of scoot-wasm (#100): floating point, bulk-memory (already landed), and a spec-style robustness/conformance suite for malformed input.

What's in this PR

Floating-point execution (W4)

  • f32/f64 arithmetic (add/sub/mul/div), unary ops (abs/neg/ceil/floor/trunc/nearest/sqrt), min/max/copysign, ordered comparisons, int/float conversions, and both trapping (iNN.trunc_fMM_s/u) and saturating (iNN.trunc_sat_fMM_s/u) truncation.
  • NaN results are canonicalized for deterministic cross-host output; abs/neg/copysign preserve exact bit patterns; nearest rounds ties to even and preserves the sign of zero.
  • The static type validator now type-checks the float opcodes, so float modules load and run end-to-end.

Robustness suite (the issue's "诚实坎")

The issue requires that malformed / malicious .wasm must return an error, not crash. New tests assert the host stays structured (load_error/trap, never a panic):

  • every truncated prefix of a valid module,
  • single-byte corruption sweep with adversarial replacements,
  • deterministic random/hostile bytes fuzz (1024 iterations, half carrying a valid header),
  • explicit load-error cases for an implausible vector length and a section length that overruns the module.

Validation

  • zig fmt --check, zig build -Dwasm-host=true, zig build test604/604 tests pass.
  • make ci passes (fmt / Debug / test / ReleaseSafe / --version smoke); pre-push local CI also green.

Docs

Updated bilingually: CHANGELOG.md / docs/CHANGELOG.zh.md, docs/WASM_TOOLS.md / docs/WASM_TOOLS.zh.md, book/en / book/zh.

Scope note

Importing the official WebAssembly spec test suite (hand-written .wat→.wasm fixtures) is intentionally out of scope here — the repo has no .wat toolchain and that is a separate, larger effort. This PR delivers the functional W4 behavior plus a structural-robustness conformance suite. Remaining full spec-conformance work can be tracked separately.

Refs #100

Finishes the W4 phase of scoot-wasm (#100): f32/f64 arithmetic, unary ops,
min/max/copysign, ordered comparisons, int/float conversions, and trapping
plus saturating truncation, with the static type validator extended to the
float opcodes so float modules load and run end-to-end. NaN results are
canonicalized for deterministic cross-host output while abs/neg/copysign
preserve exact bit patterns; nearest rounds ties to even and preserves the
zero sign.

Adds a robustness suite that feeds truncated, byte-corrupted, and
random/hostile module bytes through the loader and asserts every input yields
a structured load error or trap instead of crashing, covering the issue's
'malformed/malicious .wasm must error, not crash' requirement.

Docs updated bilingually (CHANGELOG, WASM_TOOLS, book).

Refs #100
@jamiesun
jamiesun merged commit 5ded967 into main Jun 27, 2026
7 checks passed
@jamiesun
jamiesun deleted the wasm-w4-float-and-robustness branch June 27, 2026 12:03
@jamiesun jamiesun mentioned this pull request Jun 27, 2026
jamiesun added a commit that referenced this pull request Jun 27, 2026
- wasm host W0-W4: integer, WASI preview1, type validation, float execution (#145, #147, #148, #149, #162)
- feat: wasm_tool action for compute-only packages (#154)
- wasm: narrow plugin sandbox to stdin/stdout/stderr/argv as a new hard rule (#164)
- feat: committed playground test environment with full action coverage (#161)
- release: single ReleaseSafe flavor, ship scoot-wasm artifacts, Homebrew tap (#166)
- fix(release): reference SCOOT_DOCKERHUB_* secrets so Docker Hub login is attempted
- docs: README rewrite + infographic, English comment translation (#160, #165, #146, #153)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant