Stream: git-wasmtime

Topic: wasmtime / PR #12451 Fix `OwnedRooted<T>::wasm_ty_store` ...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 18:37):

zzjas opened PR #12451 from zzjas:fix-i31ref-gc to bytecodealliance:main:

OwnedRooted<T>::wasm_ty_store unconditionally called require_gc_store_mut(), which fails with "GC heap not initialized yet" when passing an i31ref through a typed function and no GC heap has been allocated yet.

https://github.com/bytecodealliance/wasmtime/blob/ab1ab705dd93e7c944c13d4d4b2683e049f4ff73/crates/wasmtime/src/runtime/gc/enabled/rooting.rs#L1817-L1829

The sibling method Rooted<T>::wasm_ty_store already handles this by using optional_gc_store_mut() with an i31 fallback.

https://github.com/bytecodealliance/wasmtime/blob/ab1ab705dd93e7c944c13d4d4b2683e049f4ff73/crates/wasmtime/src/runtime/gc/enabled/rooting.rs#L1214-L1222

This PR makes OwnedRooted match that behavior and adds a regression test that fails without the fix and passes with it.

Without the fix, running cargo test -p wasmtime-cli --test all i31ref::owned_rooted_i31ref_through_typed_wasm_func gives:

running 1 test
test i31ref::owned_rooted_i31ref_through_typed_wasm_func ... FAILED

failures:

---- i31ref::owned_rooted_i31ref_through_typed_wasm_func stdout ----
Error: GC heap not initialized yet


failures:
    i31ref::owned_rooted_i31ref_through_typed_wasm_func

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1043 filtered out; finished in 0.01s

Thanks for looking into this!

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 18:37):

zzjas requested fitzgen for a review on PR #12451.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 18:37):

zzjas requested wasmtime-core-reviewers for a review on PR #12451.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 19:19):

fitzgen created PR review comment:

To make sure that this tests what you intend it to test even when invoked via cargo test --all-features (which is how our CI runs unit tests) we need to add config.gc_support(false) here:

    let mut config = Config::new();
    config.wasm_function_references(true);
    config.wasm_gc(true);
    config.gc_support(false);

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 19:19):

fitzgen submitted PR review:

Thanks! Looks good with one minor addition below:

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 20:48):

github-actions[bot] added the label wasmtime:api on PR #12451.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 20:48):

github-actions[bot] added the label wasmtime:ref-types on PR #12451.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 20:48):

github-actions[bot] commented on PR #12451:

Subscribe to Label Action

cc @fitzgen

<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 21:05):

zzjas created PR review comment:

Thanks for the suggestion! I tried this locally but it will break the test since (ref null any) will cause gc types are disallowed. But I also tried to run cargo test --all-features without the fix, it will correctly fail with GC heap not initialized yet. I think since the test module doesn't have gc operations so a GcStore was not created -- so the test triggers the desired path.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 21:05):

zzjas submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 21:44):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 21:44):

fitzgen created PR review comment:

Ah okay, that makes sense. Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 21:44):

fitzgen added PR #12451 Fix OwnedRooted<T>::wasm_ty_store missing i31ref check to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 22:08):

fitzgen merged PR #12451.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2026 at 22:08):

fitzgen removed PR #12451 Fix OwnedRooted<T>::wasm_ty_store missing i31ref check from the merge queue.


Last updated: Jan 29 2026 at 13:25 UTC