diff --git a/lib/vm/src/instance/mod.rs b/lib/vm/src/instance/mod.rs index bed09bbbfc6..d25810abf77 100644 --- a/lib/vm/src/instance/mod.rs +++ b/lib/vm/src/instance/mod.rs @@ -270,7 +270,15 @@ impl Instance { /// Return the indexed `VMMemoryImport`. fn imported_memory(&self, index: MemoryIndex) -> &VMMemoryImport { let index = usize::try_from(index.as_u32()).unwrap(); - unsafe { &*self.imported_memories_ptr().add(index) } + let addr = unsafe { self.imported_memories_ptr().add(index) }; + let align = std::mem::align_of::(); + debug_assert!( + addr as usize % align == 0, + "VMMemoryImport addr is not aligned to {}: {:p}", + align, + addr + ); + unsafe { &*addr } } /// Return a pointer to the `VMMemoryImport`s.