()
| 1091 | #[tokio::test] |
| 1092 | #[cfg_attr(miri, ignore)] |
| 1093 | async fn invalidated_frame_handles_in_dropped_future() -> wasmtime::Result<()> { |
| 1094 | let (module, mut store) = get_module_and_store( |
| 1095 | |_config| {}, |
| 1096 | r#" |
| 1097 | (module |
| 1098 | (import "" "" (func)) |
| 1099 | (func (export "main") |
| 1100 | call 0)) |
| 1101 | "#, |
| 1102 | )?; |
| 1103 | |
| 1104 | let handle: Arc<Mutex<Option<FrameHandle>>> = Arc::new(Mutex::new(None)); |
| 1105 | let handle_clone = handle.clone(); |
| 1106 | |
| 1107 | let hostfunc = Func::wrap_async(&mut store, move |mut caller, _args: ()| { |
| 1108 | let handle_clone = handle_clone.clone(); |
| 1109 | Box::new(async move { |
| 1110 | let frame = caller.debug_exit_frames().next().unwrap(); |
| 1111 | *handle_clone.lock().unwrap() = Some(frame); |
| 1112 | tokio::task::yield_now().await; |
| 1113 | }) |
| 1114 | }); |
| 1115 | |
| 1116 | let instance = Instance::new_async(&mut store, &module, &[Extern::Func(hostfunc)]).await?; |
| 1117 | let main = instance.get_func(&mut store, "main").unwrap(); |
| 1118 | let future = Box::pin(main.call_async(&mut store, &[], &mut [])); |
| 1119 | |
| 1120 | // Poll once, then drop. |
| 1121 | let poll_once = PollOnce::new(future); |
| 1122 | let future = poll_once.await; |
| 1123 | |
| 1124 | drop(future); |
| 1125 | |
| 1126 | // The frame handle should now be invalid. |
| 1127 | let mut handle = handle.lock().unwrap(); |
| 1128 | let frame = handle.take().unwrap(); |
| 1129 | assert!(!frame.is_valid(&mut store)); |
| 1130 | |
| 1131 | Ok(()) |
| 1132 | } |
| 1133 | |
| 1134 | #[test] |
| 1135 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected