A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Handle asyncness of core functions more often (#14758)
Alex Crichtoncd16cfe4b91f
diff --git a/crates/wasmtime/src/runtime/func.rs b/crates/wasmtime/src/runtime/func.rsindex 48ad6317cc..d7de03f1fb 100644--- a/crates/wasmtime/src/runtime/func.rs+++ b/crates/wasmtime/src/runtime/func.rs@@ -2771,10 +2771,6 @@ impl HostFunc {unsafe fn into_func(self, store: &mut StoreOpaque) -> Result<Func, OutOfMemory> {self.validate_store(store);- // This function could be called by a guest at any time, and it requires- // fibers, so the store now required async entrypoints.- store.set_async_required(self.asyncness);-let (funcrefs, modules) = store.func_refs_and_modules();let funcref = funcrefs.push_box_host(try_new::<Box<_>>(self)?, modules)?;// SAFETY: this funcref was just pushed within `store`, so it's safe to@@ -2791,6 +2787,10 @@ impl HostFunc {Engine::same(&self.engine, store.engine()),"cannot use a store with a different engine than a linker was created with",);++ // This function could be called by a guest at any time, and it requires+ // fibers, so the store now required async entrypoints.+ store.set_async_required(self.asyncness);}pub(crate) fn engine(&self) -> &Engine {diff --git a/tests/all/missing_async.rs b/tests/all/missing_async.rsindex 88786ed988..c1df009dd8 100644--- a/tests/all/missing_async.rs+++ b/tests/all/missing_async.rs@@ -86,6 +86,17 @@ async fn require_async_after_linker_with_func_new() -> Result<()> {Ok(())}+#[test]+fn require_async_after_linker_get() -> Result<()> {+ let engine = Engine::default();+ let mut store = Store::new(&engine, ());+ let mut linker = Linker::new(store.engine());+ linker.func_wrap_async("", "", |_, ()| Box::new(async {}))?;+ linker.get(&mut store, "", "").unwrap();+ assert_requires_async(&mut store);+ Ok(())+}+#[test]fn require_async_after_epochs() -> Result<()> {let mut config = Config::new();