deps: Update Arbitrary to 1.0; libfuzzer-sys to 0.4.0; wasm-smith to 0.4.0

This commit is contained in:
Nick Fitzgerald
2021-02-25 14:35:47 -08:00
committed by Andrew Brown
parent ebbe626e79
commit 824ce7bf89
7 changed files with 20 additions and 41 deletions

16
Cargo.lock generated
View File

@@ -112,9 +112,9 @@ checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
[[package]] [[package]]
name = "arbitrary" name = "arbitrary"
version = "0.4.7" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" checksum = "698b65a961a9d730fb45b6b0327e20207810c9f61ee421b082b27ba003f49e2b"
dependencies = [ dependencies = [
"derive_arbitrary", "derive_arbitrary",
] ]
@@ -863,9 +863,9 @@ dependencies = [
[[package]] [[package]]
name = "derive_arbitrary" name = "derive_arbitrary"
version = "0.4.7" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a012b5e473dc912f0db0546a1c9c6a194ce8494feb66fa0237160926f9e0e6" checksum = "df89dd0d075dea5cc5fdd6d5df6b8a61172a710b3efac1d6bdb9dd8b78f82c1a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -1442,9 +1442,9 @@ checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3"
[[package]] [[package]]
name = "libfuzzer-sys" name = "libfuzzer-sys"
version = "0.3.5" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf184a4b6b274f82a5df6b357da6055d3e82272327bba281c28bbba6f1664ef" checksum = "86c975d637bc2a2f99440932b731491fc34c7f785d239e38af3addd3c2fd0e46"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
"cc", "cc",
@@ -3058,9 +3058,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-smith" name = "wasm-smith"
version = "0.3.2" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5af0d70f17515b1bc412b7727b01304ba2484bc416da72f325d6bf4ab58f4213" checksum = "f9a5c40555e0fd974d984d9a1186cf2aa7092450912bef9943a581941dd61bfa"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
"indexmap", "indexmap",

View File

@@ -8,7 +8,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
arbitrary = { version = "0.4.1", features = ["derive"] } arbitrary = { version = "1.0.0", features = ["derive"] }
bincode = "1.2.1" bincode = "1.2.1"
env_logger = "0.8.1" env_logger = "0.8.1"
fst = "0.4.1" fst = "0.4.1"

View File

@@ -9,7 +9,6 @@
use arbitrary::{Arbitrary, Unstructured}; use arbitrary::{Arbitrary, Unstructured};
use rand::prelude::*; use rand::prelude::*;
use std::fmt::Debug; use std::fmt::Debug;
use std::panic;
use std::time; use std::time;
pub mod automata; pub mod automata;
@@ -24,7 +23,7 @@ pub mod parser;
/// for use with `cargo test` and CI. /// for use with `cargo test` and CI.
pub fn check<A>(mut f: impl FnMut(A)) pub fn check<A>(mut f: impl FnMut(A))
where where
A: Clone + Debug + Arbitrary, A: Clone + Debug + for<'a> Arbitrary<'a>,
{ {
let seed = rand::thread_rng().gen(); let seed = rand::thread_rng().gen();
let mut rng = rand::rngs::SmallRng::seed_from_u64(seed); let mut rng = rand::rngs::SmallRng::seed_from_u64(seed);
@@ -38,7 +37,7 @@ where
let time_budget = time::Duration::from_secs(2); let time_budget = time::Duration::from_secs(2);
let then = time::Instant::now(); let then = time::Instant::now();
let (failing_input, panic_info) = loop { loop {
if num_checked > 0 && time::Instant::now().duration_since(then) > time_budget { if num_checked > 0 && time::Instant::now().duration_since(then) > time_budget {
eprintln!("Checked {} random inputs.", num_checked); eprintln!("Checked {} random inputs.", num_checked);
return; return;
@@ -48,9 +47,7 @@ where
Ok(input) => { Ok(input) => {
num_checked += 1; num_checked += 1;
eprintln!("Checking input: {:#?}", input); eprintln!("Checking input: {:#?}", input);
if let Err(p) = panic::catch_unwind(panic::AssertUnwindSafe(|| f(input.clone()))) { f(input.clone());
break (input, p);
}
} }
Err(e @ arbitrary::Error::NotEnoughData) => { Err(e @ arbitrary::Error::NotEnoughData) => {
eprintln!("warning: {}", e); eprintln!("warning: {}", e);
@@ -97,23 +94,5 @@ where
for i in 0..buf.len() { for i in 0..buf.len() {
buf[i] = rng.gen(); buf[i] = rng.gen();
} }
};
// Shrink the failing input.
let mut smallest_failing_input = failing_input;
let mut panic_info = panic_info;
'shrinking: loop {
eprintln!("Smallest failing input: {:#?}", smallest_failing_input);
for input in smallest_failing_input.shrink() {
if let Err(p) = panic::catch_unwind(panic::AssertUnwindSafe(|| f(input.clone()))) {
smallest_failing_input = input;
panic_info = p;
continue 'shrinking;
}
}
break;
} }
// Resume the panic for the smallest input.
panic::resume_unwind(panic_info);
} }

View File

@@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception"
[dependencies] [dependencies]
anyhow = "1.0.22" anyhow = "1.0.22"
arbitrary = { version = "0.4.1", features = ["derive"] } arbitrary = { version = "1.0.0", features = ["derive"] }
env_logger = "0.8.1" env_logger = "0.8.1"
log = "0.4.8" log = "0.4.8"
rayon = "1.2.1" rayon = "1.2.1"
@@ -18,7 +18,7 @@ wasmprinter = "0.2.23"
wasmtime = { path = "../wasmtime" } wasmtime = { path = "../wasmtime" }
wasmtime-wast = { path = "../wast" } wasmtime-wast = { path = "../wast" }
wasm-encoder = "0.4" wasm-encoder = "0.4"
wasm-smith = "0.3.1" wasm-smith = "0.4.0"
wasmi = "0.7.0" wasmi = "0.7.0"
[dev-dependencies] [dev-dependencies]

View File

@@ -102,8 +102,8 @@ pub struct SpecTest {
pub contents: &'static str, pub contents: &'static str,
} }
impl Arbitrary for SpecTest { impl<'a> Arbitrary<'a> for SpecTest {
fn arbitrary(u: &mut Unstructured) -> arbitrary::Result<Self> { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
// NB: this does get a uniform value in the provided range. // NB: this does get a uniform value in the provided range.
let i = u.int_in_range(0..=FILES.len() - 1)?; let i = u.int_in_range(0..=FILES.len() - 1)?;
let (file, contents) = FILES[i]; let (file, contents) = FILES[i];

View File

@@ -79,8 +79,8 @@ pub struct ApiCalls {
pub calls: Vec<ApiCall>, pub calls: Vec<ApiCall>,
} }
impl Arbitrary for ApiCalls { impl<'a> Arbitrary<'a> for ApiCalls {
fn arbitrary(input: &mut Unstructured) -> arbitrary::Result<Self> { fn arbitrary(input: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
crate::init_fuzzing(); crate::init_fuzzing();
let swarm = Swarm::arbitrary(input)?; let swarm = Swarm::arbitrary(input)?;

View File

@@ -12,12 +12,12 @@ cargo-fuzz = true
cranelift-codegen = { path = "../cranelift/codegen" } cranelift-codegen = { path = "../cranelift/codegen" }
cranelift-reader = { path = "../cranelift/reader" } cranelift-reader = { path = "../cranelift/reader" }
cranelift-wasm = { path = "../cranelift/wasm" } cranelift-wasm = { path = "../cranelift/wasm" }
libfuzzer-sys = "0.3.3" libfuzzer-sys = "0.4.0"
target-lexicon = "0.11" target-lexicon = "0.11"
peepmatic-fuzzing = { path = "../cranelift/peepmatic/crates/fuzzing", optional = true } peepmatic-fuzzing = { path = "../cranelift/peepmatic/crates/fuzzing", optional = true }
wasmtime = { path = "../crates/wasmtime" } wasmtime = { path = "../crates/wasmtime" }
wasmtime-fuzzing = { path = "../crates/fuzzing" } wasmtime-fuzzing = { path = "../crates/fuzzing" }
wasm-smith = "0.3.1" wasm-smith = "0.4.0"
[features] [features]
experimental_x64 = ["wasmtime-fuzzing/experimental_x64"] experimental_x64 = ["wasmtime-fuzzing/experimental_x64"]