Throw out fewer fuzz inputs with differential fuzzer (#4859)
* Throw out fewer fuzz inputs with differential fuzzer Prior to this commit the differential fuzzer would generate a module and then select an engine to execute the module against Wasmtime. This meant, however, that the candidate list of engines were filtered against the configuration used to generate the module to ensure that the selected engine could run the generated module. This commit inverts this logic and instead selects an engine first, allowing the engine to then tweak the module configuration to ensure that the generated module is compatible with the engine selected. This means that fewer fuzz inputs are discarded because every fuzz input will result in an engine being executed. Internally the engine constructors have all been updated to update the configuration to work instead of filtering the configuration. Some other fixes were applied for the spec interpreter as well to work around #4852 * Fix tests
This commit is contained in:
@@ -1,45 +1,30 @@
|
||||
//! Evaluate an exported Wasm function using the wasmi interpreter.
|
||||
|
||||
use crate::generators::{DiffValue, DiffValueType, ModuleConfig};
|
||||
use crate::generators::{Config, DiffValue, DiffValueType};
|
||||
use crate::oracles::engine::{DiffEngine, DiffInstance};
|
||||
use anyhow::{bail, Context, Error, Result};
|
||||
use anyhow::{Context, Error, Result};
|
||||
use wasmtime::{Trap, TrapCode};
|
||||
|
||||
/// A wrapper for `wasmi` as a [`DiffEngine`].
|
||||
pub struct WasmiEngine;
|
||||
|
||||
impl WasmiEngine {
|
||||
/// Build a new [`WasmiEngine`] but only if the configuration does not rely
|
||||
/// on features that `wasmi` does not support.
|
||||
pub fn new(config: &ModuleConfig) -> Result<Self> {
|
||||
if config.config.reference_types_enabled {
|
||||
bail!("wasmi does not support reference types")
|
||||
}
|
||||
if config.config.simd_enabled {
|
||||
bail!("wasmi does not support SIMD")
|
||||
}
|
||||
if config.config.multi_value_enabled {
|
||||
bail!("wasmi does not support multi-value")
|
||||
}
|
||||
if config.config.saturating_float_to_int_enabled {
|
||||
bail!("wasmi does not support saturating float-to-int conversions")
|
||||
}
|
||||
if config.config.sign_extension_enabled {
|
||||
bail!("wasmi does not support sign-extension")
|
||||
}
|
||||
if config.config.memory64_enabled {
|
||||
bail!("wasmi does not support memory64");
|
||||
}
|
||||
if config.config.bulk_memory_enabled {
|
||||
bail!("wasmi does not support bulk memory");
|
||||
}
|
||||
if config.config.threads_enabled {
|
||||
bail!("wasmi does not support threads");
|
||||
}
|
||||
if config.config.max_memories > 1 {
|
||||
bail!("wasmi does not support multi-memory");
|
||||
}
|
||||
Ok(Self)
|
||||
pub(crate) fn new(config: &mut Config) -> Self {
|
||||
let config = &mut config.module_config.config;
|
||||
config.reference_types_enabled = false;
|
||||
config.simd_enabled = false;
|
||||
config.multi_value_enabled = false;
|
||||
config.saturating_float_to_int_enabled = false;
|
||||
config.sign_extension_enabled = false;
|
||||
config.memory64_enabled = false;
|
||||
config.bulk_memory_enabled = false;
|
||||
config.threads_enabled = false;
|
||||
config.max_memories = config.max_memories.min(1);
|
||||
config.min_memories = config.min_memories.min(1);
|
||||
config.max_tables = config.max_tables.min(1);
|
||||
config.min_tables = config.min_tables.min(1);
|
||||
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,5 +208,5 @@ impl Into<DiffValue> for wasmi::RuntimeValue {
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
crate::oracles::engine::smoke_test_engine(|config| WasmiEngine::new(&config.module_config))
|
||||
crate::oracles::engine::smoke_test_engine(|_, config| Ok(WasmiEngine::new(config)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user