Stream: git-wasmtime

Topic: wasmtime / issue #14577 Hosts throwing exceptions into co...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2026 at 17:19):

alexcrichton opened issue #14577:

This input:

use wasmtime::component::{Component, Linker};
use wasmtime::*;

fn main() -> Result<()> {
    let mut config = Config::new();
    config.wasm_exceptions(true);
    config.wasm_component_model(true);
    if std::env::var("NO_CONCURRENCY").is_ok() {
        config.concurrency_support(false);
    }
    let engine = Engine::new(&config)?;
    let component = Component::new(
        &engine,
        r#"
        (component
          (import "f" (func $f))
          (core func $f-core (canon lower (func $f)))
          (core module $m
            (import "" "f" (func $f))
            (func (export "run") (result i32)
              (block $caught
                (try_table (catch_all $caught)
                  (call $f))
                (return (i32.const 0)))
              ;; host exception observed by guest
              (i32.const 1)))
          (core instance $i (instantiate $m
            (with "" (instance (export "f" (func $f-core))))))
          (func (export "run") (result u32) (canon lift (core func $i "run"))))
        "#,
    )?;
    let mut linker = Linker::<()>::new(&engine);
    linker.root().func_wrap("f", |mut store, (): ()| {
        let ft = FuncType::new(store.engine(), [], []);
        let tag_ty = TagType::new(ft);
        let tag = Tag::new(&mut store, &tag_ty)?;
        let exn_ty = ExnType::from_tag_type(&tag_ty)?;
        let pre = ExnRefPre::new(&mut store, exn_ty);
        let exn = ExnRef::new(&mut store, &pre, &tag, &[])?;
        store.throw::<()>(exn)
    })?;
    let mut store = Store::new(&engine, ());
    let instance = linker.instantiate(&mut store, &component)?;
    let run = instance.get_typed_func::<(), (u32,)>(&mut store, "run")?;
    match run.call(&mut store, ()) {
        Ok((r,)) => println!("guest returned {r} (1 = guest caught host exception)"),
        Err(e) => println!("error: {e:?}"),
    }
    Ok(())
}

currently yields:

$ cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/host-throw`

thread 'main' (447411) panicked at /home/alex/code/wasmtime2/crates/wasmtime/src/runtime/bug.rs:63:13:
BUG: expected task when exiting
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is notably after the changes made in #14549 as well.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2026 at 17:19):

alexcrichton added the wasm-proposal:component-model label to Issue #14577.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2026 at 17:19):

alexcrichton added the wasm-proposal:exceptions label to Issue #14577.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2026 at 16:51):

fitzgen added the bug label to Issue #14577.


Last updated: Oct 11 2026 at 04:10 UTC