Skip to content

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

Fix a MIRI violation when tracing passive element segment GC roots (#13356)

Nick Fitzgeraldf6f69c7a0ef0
diff --git a/crates/wasmtime/src/runtime/vm/instance.rs b/crates/wasmtime/src/runtime/vm/instance.rs
index cd0ebcb946..3be7d97009 100644
--- a/crates/wasmtime/src/runtime/vm/instance.rs
+++ b/crates/wasmtime/src/runtime/vm/instance.rs
@@ -226,7 +226,7 @@ impl Instance {
) {
for segment in self.passive_elements_mut().iter_mut() {
if segment.needs_gc_rooting {
- for e in segment.elements() {
+ for e in segment.elements_mut() {
if e.get_vmgcref().is_none() {
continue;
}
@@ -1988,4 +1988,10 @@ impl PassiveElementSegment {
pub(crate) fn elements(&self) -> &[ValRaw] {
&self.elements
}
+
+ /// The elements of this segment.
+ #[cfg(feature = "gc")]
+ pub(crate) fn elements_mut(&mut self) -> &mut [ValRaw] {
+ &mut self.elements
+ }
}