Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Add OOM test for component TypedFunc::call_async (#13047)

Nick Fitzgerald6ad245839b92
diff --git a/crates/fuzzing/tests/oom/component_func.rs b/crates/fuzzing/tests/oom/component_func.rs
index 416a92bb39..b0124d067d 100644
--- a/crates/fuzzing/tests/oom/component_func.rs
+++ b/crates/fuzzing/tests/oom/component_func.rs
@@ -86,3 +86,45 @@ async fn component_func_call_async() -> Result<()> {
})
.await
}
+
+#[tokio::test]
+async fn component_typed_func_call_async() -> Result<()> {
+ let component_bytes = {
+ let mut config = Config::new();
+ config.concurrency_support(false);
+ let engine = Engine::new(&config)?;
+ Component::new(
+ &engine,
+ r#"
+ (component
+ (core module $m
+ (func (export "id") (param i32) (result i32) (local.get 0))
+ )
+ (core instance $i (instantiate $m))
+ (func (export "id") (param "x" s32) (result s32)
+ (canon lift (core func $i "id"))
+ )
+ )
+ "#,
+ )?
+ .serialize()?
+ };
+ let mut config = Config::new();
+ config.enable_compiler(false);
+ config.concurrency_support(false);
+ let engine = Engine::new(&config)?;
+ let component = unsafe { Component::deserialize(&engine, &component_bytes)? };
+ let linker = Linker::<()>::new(&engine);
+ let instance_pre = linker.instantiate_pre(&component)?;
+
+ OomTest::new()
+ .test_async(|| async {
+ let mut store = Store::try_new(&engine, ())?;
+ let instance = instance_pre.instantiate_async(&mut store).await?;
+ let id = instance.get_typed_func::<(i32,), (i32,)>(&mut store, "id")?;
+ let result = id.call_async(&mut store, (42,)).await?;
+ assert_eq!(result, (42,));
+ Ok(())
+ })
+ .await
+}