MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / invalidated_frame_handles_in_dropped_future

Function invalidated_frame_handles_in_dropped_future

tests/all/debug.rs:1093–1132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1091#[tokio::test]
1092#[cfg_attr(miri, ignore)]
1093async 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)]

Callers

nothing calls this directly

Calls 14

get_module_and_storeFunction · 0.85
yield_nowFunction · 0.85
OkFunction · 0.85
debug_exit_framesMethod · 0.80
newFunction · 0.50
FuncEnum · 0.50
dropFunction · 0.50
cloneMethod · 0.45
unwrapMethod · 0.45
nextMethod · 0.45
lockMethod · 0.45
get_funcMethod · 0.45

Tested by

no test coverage detected