()
| 833 | #[tokio::test] |
| 834 | #[cfg_attr(miri, ignore)] |
| 835 | async fn non_stacky_async_activations() -> Result<()> { |
| 836 | let engine = Engine::default(); |
| 837 | let mut store1: Store<Option<Pin<Box<dyn Future<Output = Result<()>> + Send>>>> = |
| 838 | Store::new(&engine, None); |
| 839 | let mut linker1 = Linker::new(&engine); |
| 840 | |
| 841 | let module1 = Module::new( |
| 842 | &engine, |
| 843 | r#" |
| 844 | (module $m1 |
| 845 | (import "" "host_capture_stack" (func $host_capture_stack)) |
| 846 | (import "" "start_async_instance" (func $start_async_instance)) |
| 847 | (func $capture_stack (export "capture_stack") |
| 848 | call $host_capture_stack |
| 849 | ) |
| 850 | (func $run_sync (export "run_sync") |
| 851 | call $start_async_instance |
| 852 | ) |
| 853 | ) |
| 854 | "#, |
| 855 | )?; |
| 856 | |
| 857 | let module2 = Module::new( |
| 858 | &engine, |
| 859 | r#" |
| 860 | (module $m2 |
| 861 | (import "" "yield" (func $yield)) |
| 862 | |
| 863 | (func $run_async (export "run_async") |
| 864 | call $yield |
| 865 | ) |
| 866 | ) |
| 867 | "#, |
| 868 | )?; |
| 869 | |
| 870 | let stacks = Arc::new(Mutex::new(vec![])); |
| 871 | fn capture_stack(stacks: &Arc<Mutex<Vec<WasmBacktrace>>>, store: impl AsContext) { |
| 872 | let mut stacks = stacks.lock().unwrap(); |
| 873 | stacks.push(wasmtime::WasmBacktrace::force_capture(store)); |
| 874 | } |
| 875 | |
| 876 | linker1.func_wrap_async("", "host_capture_stack", { |
| 877 | let stacks = stacks.clone(); |
| 878 | move |caller, _: ()| { |
| 879 | capture_stack(&stacks, &caller); |
| 880 | Box::new(async { Ok(()) }) |
| 881 | } |
| 882 | })?; |
| 883 | |
| 884 | linker1.func_wrap_async("", "start_async_instance", { |
| 885 | let stacks = stacks.clone(); |
| 886 | move |mut caller, _: ()| { |
| 887 | let stacks = stacks.clone(); |
| 888 | capture_stack(&stacks, &caller); |
| 889 | |
| 890 | let module2 = module2.clone(); |
| 891 | let mut store2 = Store::new(caller.engine(), ()); |
| 892 | let mut linker2 = Linker::<()>::new(caller.engine()); |
nothing calls this directly
no test coverage detected