fuzz: Fix infinite loops in table_ops fuzzers
I forgot in the recent refactoring to add back in fuel support to the `table_ops` fuzzer. This commit re-adds the previously existent logic to always use fuel to cancel execution of the table_ops fuzzer.
This commit is contained in:
@@ -58,7 +58,7 @@ pub struct WasmtimeConfig {
|
|||||||
debug_info: bool,
|
debug_info: bool,
|
||||||
canonicalize_nans: bool,
|
canonicalize_nans: bool,
|
||||||
interruptable: bool,
|
interruptable: bool,
|
||||||
consume_fuel: bool,
|
pub(crate) consume_fuel: bool,
|
||||||
memory_config: MemoryConfig,
|
memory_config: MemoryConfig,
|
||||||
force_jump_veneers: bool,
|
force_jump_veneers: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,15 +415,20 @@ pub fn spectest(mut fuzz_config: generators::Config, test: generators::SpecTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Execute a series of `table.get` and `table.set` operations.
|
/// Execute a series of `table.get` and `table.set` operations.
|
||||||
pub fn table_ops(fuzz_config: generators::Config, ops: generators::table_ops::TableOps) {
|
pub fn table_ops(mut fuzz_config: generators::Config, ops: generators::table_ops::TableOps) {
|
||||||
let _ = env_logger::try_init();
|
|
||||||
|
|
||||||
let expected_drops = Arc::new(AtomicUsize::new(ops.num_params() as usize));
|
let expected_drops = Arc::new(AtomicUsize::new(ops.num_params() as usize));
|
||||||
let num_dropped = Arc::new(AtomicUsize::new(0));
|
let num_dropped = Arc::new(AtomicUsize::new(0));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
fuzz_config.wasmtime.consume_fuel = true;
|
||||||
let mut store = fuzz_config.to_store();
|
let mut store = fuzz_config.to_store();
|
||||||
|
|
||||||
|
// consume the default fuel in the store ...
|
||||||
|
let remaining = store.consume_fuel(0).unwrap();
|
||||||
|
store.consume_fuel(remaining - 1).unwrap();
|
||||||
|
// ... then add back in how much fuel we're allowing here
|
||||||
|
store.add_fuel(1_000).unwrap();
|
||||||
|
|
||||||
let wasm = ops.to_wasm_binary();
|
let wasm = ops.to_wasm_binary();
|
||||||
log_wasm(&wasm);
|
log_wasm(&wasm);
|
||||||
let module = match Module::new(store.engine(), &wasm) {
|
let module = match Module::new(store.engine(), &wasm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user