From 344bf2d6f3241e1f667a8710bc5c42e0cf76422f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 6 Feb 2020 17:36:06 -0600 Subject: [PATCH] Fuzz the multi-value support (#918) * Fuzz the multi-value support This commit enables multi-value by default for the fuzzers, in theory allowing us to find panics and such in the multi-value implementation. Or even runtime errors through the differential fuzzing! * Don't fuzz differential on multi value --- crates/fuzzing/src/oracles.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs index e080829490..a43c0a50c7 100644 --- a/crates/fuzzing/src/oracles.rs +++ b/crates/fuzzing/src/oracles.rs @@ -16,6 +16,16 @@ use dummy::{dummy_imports, dummy_values}; use std::collections::{HashMap, HashSet}; use wasmtime::*; +fn fuzz_default_config(strategy: Strategy) -> Config { + let mut config = Config::new(); + config + .cranelift_debug_verifier(true) + .wasm_multi_value(true) + .strategy(strategy) + .expect("failed to enable lightbeam"); + return config; +} + /// Instantiate the Wasm buffer, and implicitly fail if we have an unexpected /// panic or segfault or anything else that can be detected "passively". /// @@ -23,12 +33,7 @@ use wasmtime::*; /// /// You can control which compiler is used via passing a `Strategy`. pub fn instantiate(wasm: &[u8], strategy: Strategy) { - let mut config = Config::new(); - config - .cranelift_debug_verifier(true) - .strategy(strategy) - .expect("failed to enable lightbeam"); - instantiate_with_config(wasm, config); + instantiate_with_config(wasm, fuzz_default_config(strategy)); } /// Instantiate the Wasm buffer, and implicitly fail if we have an unexpected @@ -70,12 +75,7 @@ pub fn instantiate_with_config(wasm: &[u8], config: Config) { /// /// You can control which compiler is used via passing a `Strategy`. pub fn compile(wasm: &[u8], strategy: Strategy) { - let mut config = Config::new(); - config - .cranelift_debug_verifier(true) - .strategy(strategy) - .unwrap(); - let engine = Engine::new(&config); + let engine = Engine::new(&fuzz_default_config(strategy)); let store = Store::new(&engine); let _ = Module::new(&store, wasm); }