Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few more small fuzzing fixes #2770

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/fuzzing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ pub fn fuzz_default_config(strategy: wasmtime::Strategy) -> anyhow::Result<wasmt
.wasm_bulk_memory(true)
.wasm_reference_types(true)
.wasm_module_linking(true)
.max_instances(100)
.max_tables(100)
.max_memories(100)
// The limits here are chosen based on the default "maximum type size"
// configured in wasm-smith, which is 1000. This means that instances
// are allowed to, for example, export up to 1000 memories. We bump that
// a little bit here to give us some slop.
.max_instances(1100)
.max_tables(1100)
.max_memories(1100)
.strategy(strategy)?;
Ok(config)
}
10 changes: 7 additions & 3 deletions crates/fuzzing/src/oracles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ fn log_wasm(wasm: &[u8]) {
let name = format!("testcase{}.wasm", i);
std::fs::write(&name, wasm).expect("failed to write wasm file");
log::debug!("wrote wasm file to `{}`", name);
if let Ok(s) = wasmprinter::print_bytes(wasm) {
let name = format!("testcase{}.wat", i);
std::fs::write(&name, s).expect("failed to write wat file");
let wat = format!("testcase{}.wat", i);
match wasmprinter::print_bytes(wasm) {
Ok(s) => 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)),
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/fuzzing/src/oracles/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down