Stream: git-wasmtime

Topic: wasmtime / issue #13344 GcRuntime::vmctx_gc_heap_data is ...


view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 22:12):

alexcrichton opened issue #13344:

This is preexisting I think for other collectors, but there's 2 primary ways that this method is UB according to Miri:

  1. This is deriving a pointer from &self which is later mutated through in compiled code. That's UB in Rust because by deriving the pointer from &self you're saying that the contents can't be mutated. This is a playground example showing the UB (top right, Tools -> Miri). The fix for this specific issue is to change this method to &mut self and then have the implementation be NonNull::from(&mut self.vmctx_data).cast()
  2. The second problem is that this struture is stored inline with the CopyingHeap, which means that re-acquiring a mutable pointer to CopyingHeap will actually invalidate the previous pointer returned by this method. This is a playground example of the UB here.

Fixing the latter one is not going to be super easy. I can think a few possible ways:

I haven't double-checked, but I believe this would all plague the drc/null collectors as well. If you'd like I think it'd be reasonable to fix them all in a subsequent PR.

In terms of detecting all of this, in theory Miri should be able to capture everything here. I think that may mean we're not running much GC-compiled wasms through Miri, which might be a good addition to have? For miri coverage copying this line is probably the easiest. Along those lines rustup run nightly ./ci/miri-wast.sh ./tests/spec_testsuite/struct.wast locally shows a Miri violation which may be related to this, but it's always sort of hard to tell where exactly the miri error comes from due to the mix of pulley and lack of strict provenance...

_Originally posted by @alexcrichton in https://github.com/bytecodealliance/wasmtime/pull/13323#discussion_r3209562532_

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 22:12):

alexcrichton added the wasm-proposal:gc label to Issue #13344.

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 22:12):

alexcrichton assigned fitzgen to issue #13344.

view this post on Zulip Wasmtime GitHub notifications bot (May 21 2026 at 18:50):

fitzgen closed issue #13344:

This is preexisting I think for other collectors, but there's 2 primary ways that this method is UB according to Miri:

  1. This is deriving a pointer from &self which is later mutated through in compiled code. That's UB in Rust because by deriving the pointer from &self you're saying that the contents can't be mutated. This is a playground example showing the UB (top right, Tools -> Miri). The fix for this specific issue is to change this method to &mut self and then have the implementation be NonNull::from(&mut self.vmctx_data).cast()
  2. The second problem is that this struture is stored inline with the CopyingHeap, which means that re-acquiring a mutable pointer to CopyingHeap will actually invalidate the previous pointer returned by this method. This is a playground example of the UB here.

Fixing the latter one is not going to be super easy. I can think a few possible ways:

I haven't double-checked, but I believe this would all plague the drc/null collectors as well. If you'd like I think it'd be reasonable to fix them all in a subsequent PR.

In terms of detecting all of this, in theory Miri should be able to capture everything here. I think that may mean we're not running much GC-compiled wasms through Miri, which might be a good addition to have? For miri coverage copying this line is probably the easiest. Along those lines rustup run nightly ./ci/miri-wast.sh ./tests/spec_testsuite/struct.wast locally shows a Miri violation which may be related to this, but it's always sort of hard to tell where exactly the miri error comes from due to the mix of pulley and lack of strict provenance...

_Originally posted by @alexcrichton in https://github.com/bytecodealliance/wasmtime/pull/13323#discussion_r3209562532_


Last updated: Jun 01 2026 at 09:49 UTC