A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Add support for collecting garbage to the public API fuzzer (#13457)
Nick Fitzgerald96b5b82dfed5
diff --git a/crates/fuzzing/src/generators/api.rs b/crates/fuzzing/src/generators/api.rsindex 3836bf608f..cbdea7c97a 100644--- a/crates/fuzzing/src/generators/api.rs+++ b/crates/fuzzing/src/generators/api.rs@@ -45,6 +45,7 @@ impl FuzzValType {struct Swarm {store_new: bool,store_drop: bool,+ store_gc: bool,module_new: bool,module_drop: bool,instance_new: bool,@@ -148,6 +149,9 @@ pub enum ApiCall {StoreDrop {id: usize,},+ StoreGc {+ id: usize,+ },ModuleNew {id: usize,wasm: Vec<u8>,@@ -668,6 +672,13 @@ impl<'a> Arbitrary<'a> for ApiCalls {Ok(StoreDrop { id })});}+ if swarm.store_gc && !scope.stores.is_empty() {+ choices.push(|input, scope| {+ let stores: Vec<_> = scope.stores.iter().collect();+ let id = **input.choose(&stores)?;+ Ok(StoreGc { id })+ });+ }if swarm.module_new {choices.push(|input, scope| {let id = scope.next_id();diff --git a/crates/fuzzing/src/oracles/api.rs b/crates/fuzzing/src/oracles/api.rsindex 15136af397..df2584e341 100644--- a/crates/fuzzing/src/oracles/api.rs+++ b/crates/fuzzing/src/oracles/api.rs@@ -65,6 +65,15 @@ pub fn make_api_calls(api: ApiCalls) {stores.remove(&id);}+ ApiCall::StoreGc { id } => {+ log::trace!("collecting garbage in store {id}");+ let st = match stores.get_mut(&id) {+ Some(s) => s,+ None => continue,+ };+ let _ = st.gc(None);+ }+ApiCall::ModuleNew { id, wasm } => {log::debug!("creating module: {id}");log_wasm(&wasm);