fitzgen opened PR #13166 from fitzgen:issue-13037 to bytecodealliance:main:
The
expose_gc_ref_to_wasmfunction takes ownership of a GC reference in the process of exposing it to raw Wasm code. For the DRC collector, this inserts the GC ref into the over-approximated-stack-roots list, as the Wasm stack logically holds a reference to the object. That reference is cleaned up when we scan the stack during GC and consolidate between what is actually still in use on the Wasm stack vs what is only in the OASR list.However, the OASR list cannot contain duplicates (it is an intrusive linked list in the DRC object header) so if the object was already in the list, then we would not insert it into the list again. But this then causes leaks because
expose_gc_ref_to_wasmtook ownership of the GC reference because the OASR list clean up during GC only decrefs a single time.The solution is to decref in
expose_gc_ref_to_wasmwhen the object is already in the OASR list.Fixes #13037
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
fitzgen requested alexcrichton for a review on PR #13166.
fitzgen requested wasmtime-core-reviewers for a review on PR #13166.
alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #13166.
alexcrichton added PR #13166 Fix DRC leak when passing same object to Wasm multiple times to the merge queue.
github-merge-queue[bot] removed PR #13166 Fix DRC leak when passing same object to Wasm multiple times from the merge queue.
github-actions[bot] added the label wasmtime:ref-types on PR #13166.
github-actions[bot] added the label wasmtime:api on PR #13166.
github-actions[bot] commented on PR #13166:
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>
fitzgen updated PR #13166.
fitzgen has enabled auto merge for PR #13166.
fitzgen added PR #13166 Fix DRC leak when passing same object to Wasm multiple times to the merge queue.
fitzgen merged PR #13166.
fitzgen removed PR #13166 Fix DRC leak when passing same object to Wasm multiple times from the merge queue.
Last updated: May 03 2026 at 22:13 UTC