From 516a97b3f3017ff86180acac74debde75d16186a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Mar 2021 18:44:04 -0500 Subject: [PATCH] A few more small fuzzing fixes (#2770) * Increase allowances for values when fuzzing The wasm-smith limits for generating modules are a bit higher than what we specify, so sync those up to avoid getting too many false positives with limits getting blown. * Ensure fuzzing `*.wat` files are in sync I keep looking at `*.wat` files that are actually stale, so remove stale files if we write out a `*.wasm` file and can't disassemble it. * Enable shadowing in dummy_linker Fixes an issues where the same name is imported twice and we generated two values for that. We don't mind the error here, we just want to ignore the shadowing errors. --- crates/fuzzing/src/lib.rs | 10 +++++++--- crates/fuzzing/src/oracles.rs | 10 +++++++--- crates/fuzzing/src/oracles/dummy.rs | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/fuzzing/src/lib.rs b/crates/fuzzing/src/lib.rs index d131149ddb..6e4e991c4c 100644 --- a/crates/fuzzing/src/lib.rs +++ b/crates/fuzzing/src/lib.rs @@ -39,9 +39,13 @@ pub fn fuzz_default_config(strategy: wasmtime::Strategy) -> anyhow::Result std::fs::write(&wat, s).expect("failed to write wat file"), + // If wasmprinter failed remove a `*.wat` file, if any, to avoid + // confusing a preexisting one with this wasm which failed to get + // printed. + Err(_) => drop(std::fs::remove_file(&wat)), } } diff --git a/crates/fuzzing/src/oracles/dummy.rs b/crates/fuzzing/src/oracles/dummy.rs index 565d510cfd..f03bbfa067 100644 --- a/crates/fuzzing/src/oracles/dummy.rs +++ b/crates/fuzzing/src/oracles/dummy.rs @@ -6,6 +6,7 @@ use wasmtime::*; /// Create a set of dummy functions/globals/etc for the given imports. pub fn dummy_linker<'module>(store: &Store, module: &Module) -> Linker { let mut linker = Linker::new(store); + linker.allow_shadowing(true); for import in module.imports() { match import.name() { Some(name) => {