Skip to content

Commit

Permalink
Fix the no-traps fuzzer when memory runs out (#828)
Browse files Browse the repository at this point in the history
Allow another instance of a trap when an instance runs out of memory due
to wanting to create too many tables or too many memories or similar.
  • Loading branch information
alexcrichton committed Nov 18, 2022
1 parent 1095eaf commit a44c779
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fuzz/fuzz_targets/no-traps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,18 @@ fuzz_target!(|data: &[u8]| {
.and_then(|imports| Instance::new(&mut store, &module, &imports));
let instance = match inst_result {
Ok(r) => r,
Err(err) if err.to_string().contains("all fuel consumed") => return,
Err(err) => panic!("generated wasm trapped in non-trapping mode: {}", err),
Err(err) => {
let s = err.to_string();
// Allow "nominal" traps such as running out of fuel and the
// module trying to allocate more resources than we'd like to
// allow it (e.g. lots of memories or lots of tables).
if s.contains("all fuel consumed") || s.contains("Insufficient resources") {
return;
}

// Otherwise though this is a bug.
panic!("generated wasm trapped in non-trapping mode: {}", err)
}
};

// Call all exported functions
Expand Down

0 comments on commit a44c779

Please sign in to comment.