alexcrichton opened issue #13308:
This test:
#[tokio::test] async fn take_exception_in_debug_handler() -> wasmtime::Result<()> { let mut config = Config::new(); config.wasm_exceptions(true); config.guest_debug(true); let engine = Engine::new(&config)?; let mut store = Store::new(&engine, ()); store.set_debug_handler(TakeExceptionHandler); let module = Module::new( &engine, r#" (module (tag $t) (func (export "run") (block $h (try_table (catch_all $h) (throw $t))) ) ) "#, )?; let instance = Instance::new_async(&mut store, &module, &[]).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; let err = run.call_async(&mut store, ()).await.unwrap_err(); assert!(err.is::<wasmtime::ThrownException>()); return Ok(()); #[derive(Clone)] struct TakeExceptionHandler; impl DebugHandler for TakeExceptionHandler { type Data = (); fn handle( &self, mut store: StoreContextMut<'_, ()>, event: DebugEvent<'_>, ) -> impl Future<Output = ()> + Send { let did_take = matches!(event, DebugEvent::CaughtExceptionThrown(_)); // Eat the pending exception that compute_handler put back. if did_take { let _ = store.take_pending_exception(); } async move {} } } }fails with:
$ cargo test --test all take_exception_in_debug Finished `test` profile [unoptimized + debuginfo] target(s) in 0.12s Running tests/all/main.rs (target/debug/deps/all-559dd3ff47d782d6) running 1 test thread 'debug::take_exception_in_debug_handler' (2522963) panicked at crates/wasmtime/src/runtime/vm/traphandlers.rs:931:26: called `Option::unwrap()` on a `None` value note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'debug::take_exception_in_debug_handler' (2522963) panicked at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/core/src/panicking.rs:225:5: panic in a function that cannot unwind stack backtrace: ... (big stack trace) ... error: test failed, to rerun pass `--test all` Caused by: process didn't exit successfully: `/home/alex/code/wasmtime/target/debug/deps/all-559dd3ff47d782d6 take_exception_in_debug` (signal: 6, SIGABRT: process abort signal)
alexcrichton added the wasm-proposal:exceptions label to Issue #13308.
alexcrichton assigned alexcrichton to issue #13308.
alexcrichton added the wasm-proposal:gc label to Issue #13308.
alexcrichton removed the wasm-proposal:gc label from Issue #13308.
alexcrichton closed issue #13308:
This test:
#[tokio::test] async fn take_exception_in_debug_handler() -> wasmtime::Result<()> { let mut config = Config::new(); config.wasm_exceptions(true); config.guest_debug(true); let engine = Engine::new(&config)?; let mut store = Store::new(&engine, ()); store.set_debug_handler(TakeExceptionHandler); let module = Module::new( &engine, r#" (module (tag $t) (func (export "run") (block $h (try_table (catch_all $h) (throw $t))) ) ) "#, )?; let instance = Instance::new_async(&mut store, &module, &[]).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; let err = run.call_async(&mut store, ()).await.unwrap_err(); assert!(err.is::<wasmtime::ThrownException>()); return Ok(()); #[derive(Clone)] struct TakeExceptionHandler; impl DebugHandler for TakeExceptionHandler { type Data = (); fn handle( &self, mut store: StoreContextMut<'_, ()>, event: DebugEvent<'_>, ) -> impl Future<Output = ()> + Send { let did_take = matches!(event, DebugEvent::CaughtExceptionThrown(_)); // Eat the pending exception that compute_handler put back. if did_take { let _ = store.take_pending_exception(); } async move {} } } }fails with:
$ cargo test --test all take_exception_in_debug Finished `test` profile [unoptimized + debuginfo] target(s) in 0.12s Running tests/all/main.rs (target/debug/deps/all-559dd3ff47d782d6) running 1 test thread 'debug::take_exception_in_debug_handler' (2522963) panicked at crates/wasmtime/src/runtime/vm/traphandlers.rs:931:26: called `Option::unwrap()` on a `None` value note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'debug::take_exception_in_debug_handler' (2522963) panicked at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/core/src/panicking.rs:225:5: panic in a function that cannot unwind stack backtrace: ... (big stack trace) ... error: test failed, to rerun pass `--test all` Caused by: process didn't exit successfully: `/home/alex/code/wasmtime/target/debug/deps/all-559dd3ff47d782d6 take_exception_in_debug` (signal: 6, SIGABRT: process abort signal)
Last updated: Jun 01 2026 at 09:49 UTC