alexcrichton assigned dicej to issue #11348.
alexcrichton opened issue #11348:
Lowering into WebAssembly may require calling the
realloccomponent model abi option to allocate space for a returned list, for example. WebAssembly in async mode must always be invoked on a fiber to support suspension at any time, for example with epochs or fuel injecting yields. Currently the component-model-async implementation does not always create and use aLowerContexton a fiber which will result in panics that fiber-related contextual information is unavailable.This was discovered in review of https://github.com/bytecodealliance/wasmtime/pull/11325 and while that has an attempted solution for futures and streams it was also discovered that the solution isn't complete. I'm opening issue to keep track of this and take notes over time as necessary.
I shared with @dicej a small patch:
diff --git a/crates/wasmtime/src/runtime/component/func/options.rs b/crates/wasmtime/src/runtime/component/func/options.rs index 620e5a71d5..a839772824 100644 --- a/crates/wasmtime/src/runtime/component/func/options.rs +++ b/crates/wasmtime/src/runtime/component/func/options.rs @@ -241,6 +241,11 @@ impl<'a, T: 'static> LowerContext<'a, T> { types: &'a ComponentTypes, instance: Instance, ) -> LowerContext<'a, T> { + if cfg!(debug_assertions) { + if store.engine().config().async_support { + store.0.with_blocking(|_, _| {}); + } + } LowerContext { store, options,which can be used to assert that
LowerContextis created on a fiber. This currently panics many tests in thecomponent-async-testscrate (and probably others). The current plan is to fix these panics then perhaps move this assertion toreallocinstead to have a fast path where "flat" types can skip the fiber if they don't need realloc.
alexcrichton added the wasm-proposal:component-model-async label to Issue #11348.
dicej closed issue #11348:
Lowering into WebAssembly may require calling the
realloccomponent model abi option to allocate space for a returned list, for example. WebAssembly in async mode must always be invoked on a fiber to support suspension at any time, for example with epochs or fuel injecting yields. Currently the component-model-async implementation does not always create and use aLowerContexton a fiber which will result in panics that fiber-related contextual information is unavailable.This was discovered in review of https://github.com/bytecodealliance/wasmtime/pull/11325 and while that has an attempted solution for futures and streams it was also discovered that the solution isn't complete. I'm opening issue to keep track of this and take notes over time as necessary.
I shared with @dicej a small patch:
diff --git a/crates/wasmtime/src/runtime/component/func/options.rs b/crates/wasmtime/src/runtime/component/func/options.rs index 620e5a71d5..a839772824 100644 --- a/crates/wasmtime/src/runtime/component/func/options.rs +++ b/crates/wasmtime/src/runtime/component/func/options.rs @@ -241,6 +241,11 @@ impl<'a, T: 'static> LowerContext<'a, T> { types: &'a ComponentTypes, instance: Instance, ) -> LowerContext<'a, T> { + if cfg!(debug_assertions) { + if store.engine().config().async_support { + store.0.with_blocking(|_, _| {}); + } + } LowerContext { store, options,which can be used to assert that
LowerContextis created on a fiber. This currently panics many tests in thecomponent-async-testscrate (and probably others). The current plan is to fix these panics then perhaps move this assertion toreallocinstead to have a fast path where "flat" types can skip the fiber if they don't need realloc.
dicej commented on issue #11348:
Fixed by #11353
Last updated: Dec 06 2025 at 06:05 UTC