A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Fix a `bail_bug!` when the event loop isn't running (#14951)
Alex Crichtonea4d25060538
diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rsindex cfc3ed676e..d7efe81cba 100644--- a/crates/wasmtime/src/runtime/component/concurrent.rs+++ b/crates/wasmtime/src/runtime/component/concurrent.rs@@ -3515,8 +3515,15 @@ impl Instance {let guest_thread = store.0.current_guest_thread()?;let state = store.0.concurrent_state_mut()?;+ // FIXME(#14950): this in theory should be a `bail_bug!`, but this can+ // be hit through `Func::call` for example. This isn't great because it+ // means that `Func::call` is sort of fundamentally incompatible with+ // component-model-async...if !state.event_loop_running {- bail_bug!("Instance::start_call called without a running event loop");+ bail!(+ "async function started during an original synchronous \+ entrypoint; please use an async-style entrypoint instead"+ );}let callee = SendSyncPtr::new(callee);diff --git a/tests/all/component_model/async.rs b/tests/all/component_model/async.rsindex 882a4ef95d..ef30bf6e0f 100644--- a/tests/all/component_model/async.rs+++ b/tests/all/component_model/async.rs@@ -2807,6 +2807,33 @@ fn sync_call_async_typed() -> Result<()> {);}+ // Somehow this shouldn't hit `bail-bug!` at least...+ const WAT2: &str = r#"+(component+ (component $inner+ (core module $m+ (func (export "f") (param i32) (result i32)+ (i32.add (local.get 0) (i32.const 3))))+ (core instance $i (instantiate $m))+ (func (export "f") async (param "x" u32) (result u32)+ (canon lift (core func $i "f"))))+ (instance $inner (instantiate $inner))++ (core func $f (canon lower (func $inner "f")))+ (core module $m+ (import "" "f" (func $f (param i32) (result i32)))+ (func (export "run") (param i32) (result i32) (call $f (local.get 0))))+ (core instance $i (instantiate $m (with "" (instance (export "f" (func $f))))))+ (func (export "run") (param "x" u32) (result u32)+ (canon lift (core func $i "run")))+)+"#;+ let component = Component::new(&engine, WAT2)?;+ let mut store = Store::new(&engine, ());+ let instance = Linker::new(&engine).instantiate(&mut store, &component)?;+ let func = instance.get_typed_func::<(u32,), (u32,)>(&mut store, "run")?;+ let _ = func.call(&mut store, (4,));+Ok(())}