-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Lowering into WebAssembly may require calling the realloc component 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 a LowerContext on a fiber which will result in panics that fiber-related contextual information is unavailable.
This was discovered in review of #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 LowerContext is created on a fiber. This currently panics many tests in the component-async-tests crate (and probably others). The current plan is to fix these panics then perhaps move this assertion to realloc instead to have a fast path where "flat" types can skip the fiber if they don't need realloc.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status