alexcrichton opened issue #14594:
Similar to the other fuel issues we've seen recently -- mutations to fuel in the debug handler don't have any effect. This program panics because the guest ran to completion:
use wasmtime::*; #[derive(Clone)] struct Handler; impl DebugHandler for Handler { type Data = (); async fn handle(&self, mut store: StoreContextMut<'_, ()>, event: DebugEvent<'_>) { if let DebugEvent::Breakpoint = event { store.set_fuel(0).unwrap(); } } } #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { let mut config = Config::new(); config.guest_debug(true); config.consume_fuel(true); let engine = Engine::new(&config)?; let module = Module::new( &engine, r#"(module (func (export "count") (param $n i32) (result i32) (local $i i32) (loop $l (local.set $i (i32.add (local.get $i) (i32.const 1))) (br_if $l (i32.lt_u (local.get $i) (local.get $n)))) (local.get $i)))"#, )?; let mut store = Store::new(&engine, ()); store.set_fuel(1_000_000)?; store.set_debug_handler(Handler); store.edit_breakpoints().unwrap().single_step(true)?; let instance = Instance::new_async(&mut store, &module, &[]).await?; let count = instance.get_typed_func::<i32, i32>(&mut store, "count")?; let result = count.call_async(&mut store, 100).await; println!( "result = {result:?}, fuel afterwards = {}", store.get_fuel()? ); assert!(result.is_err(), "set_fuel(0) in debug handler was ignored"); Ok(()) }
alexcrichton added the wasmtime:debugging label to Issue #14594.
alexcrichton added the wasmtime:fuel label to Issue #14594.
alexcrichton added the bug label to Issue #14594.
Last updated: Oct 11 2026 at 04:10 UTC