Skip to content

Commit

Permalink
Remove impl Default from our WasmSmithModule wrappers.
Browse files Browse the repository at this point in the history
Manually impl Arbitrary in equivalence jit so that we can apply the termination there. This applies it in one place whether we're in cargo fuzz run or in cargo fuzz fmt.
  • Loading branch information
nlewycky committed Apr 16, 2021
1 parent f0e5f2f commit b2ad87f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions fuzz/fuzz_targets/equivalence_jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ impl Config for ExportedFunctionConfig {
}
}

#[derive(Arbitrary)]
struct WasmSmithModule(ConfiguredModule<ExportedFunctionConfig>);
impl Default for WasmSmithModule {
fn default() -> Self {
let mut inner = ConfiguredModule::<ExportedFunctionConfig>::default();
inner.ensure_termination(100000);
Self(inner)
impl<'a> arbitrary::Arbitrary<'a> for WasmSmithModule {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let mut module = ConfiguredModule::<ExportedFunctionConfig>::arbitrary(u)?;
module.ensure_termination(100000);
Ok(WasmSmithModule(module))
}
}
impl std::fmt::Debug for WasmSmithModule {
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/jit_cranelift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Config for NoImportsConfig {
false
}
}
#[derive(Default, Arbitrary)]
#[derive(Arbitrary)]
struct WasmSmithModule(ConfiguredModule<NoImportsConfig>);
impl std::fmt::Debug for WasmSmithModule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/jit_llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Config for NoImportsConfig {
false
}
}
#[derive(Default, Arbitrary)]
#[derive(Arbitrary)]
struct WasmSmithModule(ConfiguredModule<NoImportsConfig>);
impl std::fmt::Debug for WasmSmithModule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/jit_singlepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Config for NoImportsConfig {
false
}
}
#[derive(Default, Arbitrary)]
#[derive(Arbitrary)]
struct WasmSmithModule(ConfiguredModule<NoImportsConfig>);
impl std::fmt::Debug for WasmSmithModule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/metering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Config for NoImportsConfig {
}
}

#[derive(Default, Arbitrary)]
#[derive(Arbitrary)]
struct WasmSmithModule(ConfiguredModule<NoImportsConfig>);
impl std::fmt::Debug for WasmSmithModule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/native_cranelift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Config for NoImportsConfig {
false
}
}
#[derive(Default, Arbitrary)]
#[derive(Arbitrary)]
struct WasmSmithModule(ConfiguredModule<NoImportsConfig>);
impl std::fmt::Debug for WasmSmithModule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down

0 comments on commit b2ad87f

Please sign in to comment.