zzjas opened PR #12451 from zzjas:fix-i31ref-gc to bytecodealliance:main:
OwnedRooted<T>::wasm_ty_storeunconditionally calledrequire_gc_store_mut(), which fails with "GC heap not initialized yet" when passing ani31refthrough a typed function and no GC heap has been allocated yet.The sibling method
Rooted<T>::wasm_ty_storealready handles this by usingoptional_gc_store_mut()with an i31 fallback.This PR makes
OwnedRootedmatch 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_funcgives: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.01sThanks for looking into this!
zzjas requested fitzgen for a review on PR #12451.
zzjas requested wasmtime-core-reviewers for a review on PR #12451.
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 addconfig.gc_support(false)here:let mut config = Config::new(); config.wasm_function_references(true); config.wasm_gc(true); config.gc_support(false);
fitzgen submitted PR review:
Thanks! Looks good with one minor addition below:
github-actions[bot] added the label wasmtime:api on PR #12451.
github-actions[bot] added the label wasmtime:ref-types on PR #12451.
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:
- fitzgen: wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
zzjas created PR review comment:
Thanks for the suggestion! I tried this locally but it will break the test since
(ref null any)will causegc types are disallowed. But I also tried to runcargo test --all-featureswithout the fix, it will correctly fail withGC 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.
zzjas submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
Ah okay, that makes sense. Thanks!
fitzgen added PR #12451 Fix OwnedRooted<T>::wasm_ty_store missing i31ref check to the merge queue.
fitzgen merged PR #12451.
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