From 5ac961607fe067991ac06d5c18f6e859de9f66b9 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Fri, 24 Dec 2021 17:13:23 -0800 Subject: [PATCH] fuzzbug fix --- fuzz/fuzz_targets/straightline_differential.rs | 5 +++++ src/frontend.rs | 1 + 2 files changed, 6 insertions(+) diff --git a/fuzz/fuzz_targets/straightline_differential.rs b/fuzz/fuzz_targets/straightline_differential.rs index 4eeb23a..177edd1 100644 --- a/fuzz/fuzz_targets/straightline_differential.rs +++ b/fuzz/fuzz_targets/straightline_differential.rs @@ -121,6 +121,11 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { let parsed_module = Module::from_wasm_bytes(&orig_bytes[..]).unwrap(); let roundtrip_bytes = parsed_module.to_wasm_bytes(); + if let Ok(filename) = std::env::var("FUZZ_DUMP_WASM") { + std::fs::write(format!("{}_orig.wasm", filename), &orig_bytes[..]).unwrap(); + std::fs::write(format!("{}_roundtrip.wasm", filename), &roundtrip_bytes[..]).unwrap(); + } + let roundtrip_module = wasmtime::Module::new(&engine, &roundtrip_bytes[..]) .expect("failed to parse roundtripped wasm"); let roundtrip_instance = wasmtime::Instance::new(&mut store, &roundtrip_module, &[]) diff --git a/src/frontend.rs b/src/frontend.rs index 68dd6b0..669cb12 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -1134,6 +1134,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> { let values = values.to_vec(); self.body.end_block(block, Terminator::Return { values }); } + self.cur_block = None; } fn push_block_params(&mut self, num_params: usize) {