Skip to content

Commit 2278bd2

Browse files
authored
Document subtlety of safety conditions for vm::Instance::sibling_vmctx_mut (#11318)
I initially thought that the documentation was missing a safety invariant that callers must uphold, and then realized that it was a little subtler than I originally thought, so I updated the documentation to clarify this for future readers.
1 parent 3e1400e commit 2278bd2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/wasmtime/src/runtime/vm/instance.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ impl Instance {
354354
///
355355
/// This function requires that the `vmctx` pointer is indeed valid and
356356
/// from the store that `self` belongs to.
357+
///
358+
/// (Note that it is *NOT* required that `vmctx` be distinct from this
359+
/// instance's `vmctx`, or that usage of the resulting instance is limited
360+
/// to its defined items! The returned borrow has the same lifetime as
361+
/// `self`, which means that this instance cannot be used while the
362+
/// resulting instance is in use, and we therefore do not need to worry
363+
/// about mutable aliasing between this instance and the resulting
364+
/// instance.)
357365
#[inline]
358366
unsafe fn sibling_vmctx_mut<'a>(
359367
self: Pin<&'a mut Self>,

0 commit comments

Comments
 (0)