Skip to content

decode seeds with the matching fuzz-target generator#71

Open
kokroo wants to merge 2 commits into
nasa:mainfrom
kokroo:fix/seed-to-wasm-target
Open

decode seeds with the matching fuzz-target generator#71
kokroo wants to merge 2 commits into
nasa:mainfrom
kokroo:fix/seed-to-wasm-target

Conversation

@kokroo

@kokroo kokroo commented Jul 12, 2026

Copy link
Copy Markdown

seed_to_wasm always decodes seeds with NoTrapsModule but the validate fuzz target uses FuzzModule. The two configure wasm-smith differently (no_traps sets disallow_traps), so they consume input bytes differently and produce different modules from the same seed. So reproducing a validate crash via make trace rebuilt a different module than the one that crashed.

Fix

  • Add a wasm_from_seed(seed, target) helper to the fuzzing library and a --target no_traps|validate flag to the binary. Default stays no_traps, so existing usage is unchanged.
  • Thread an optional TARGET variable through the Makefile trace/seed-to-wasm targets, and add the missing -- separator so arguments actually reach the binary.

Tests

Added tests to prove that the two generators produce different wasm from the same seed and that the generation is deterministic.

Usage

make trace CRASH=fuzz/artifacts/validate/crash-xxx TARGET=validate

This bug cooked my brain before I figured out why debugging does not work. Hopefullt this will stay fixed for good now.

Closes #47

seed_to_wasm always decoded seeds with NoTrapsModule, but the `validate`
fuzz target generates modules with FuzzModule. The two configure wasm-smith
differently (no_traps sets disallow_traps), so they consume input bytes
differently and produce different modules from the same seed, reproducing a
`validate` crash reconstructed the wrong module.

Add a `wasm_from_seed(seed, target)` helper to the fuzzing library and a
`--target no_traps|validate` flag to the binary (default no_traps, so existing
usage is unchanged). Thread an optional TARGET variable through the Makefile
trace/seed-to-wasm targets, and add the missing `--` separator so arguments
actually reach the binary.

Add tests that the two generators produce different wasm from the same seed and
that generation is deterministic.
@github-actions

Copy link
Copy Markdown

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly

@kokroo

kokroo commented Jul 12, 2026

Copy link
Copy Markdown
Author

@Kronos3 I added tests for posterity. Maybe this "bug" will not be a bug some time in the future due to changes in Rust, the compiler, or the WA spec itself. Let me know if the tests should stay in the PR in addition to the "fix".

@github-actions

Copy link
Copy Markdown

CoreMark Benchmark Results

Current Score: 261.199
Baseline Score (main): 230.362
Difference: +30.837 (13.39%)

@github-actions

Copy link
Copy Markdown

Code Coverage Report

Current Coverage: 93.64%
Baseline Coverage (main): 93.64%
Difference: +0.00%

@Anantdadhich

Copy link
Copy Markdown

Yeah, was thinking about that too , if we go the env var route, running
seed_to_wasm by hand outside of make just won't know the target and'll
quietly decode the wrong module, which kind of defeats the point. Also
ties the core library to the environment, which feels off.

Doing it as a --target flag on the CLI tool with path auto-detection
covers both cases , works through make and when you run it manually ..
and keeps the library itself clean.

@kokroo

kokroo commented Jul 13, 2026

Copy link
Copy Markdown
Author

@Kronos3 I'm a bit confused by the automated benchmark result. My changes in this PR should not have influenced the CoreMark benchmark in any way yet the bot reports an increase in the score.

Is it possible that the machines used by Github Runners are different at times and the hardware is faster? I'm also not sure if that benchmark is hardware agnostic and actually measures CPU time instead of wall time.

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.

seed_to_wasm rebuilds the wrong module for validate-target crashes

2 participants