Skip to content

Fix leaking GC heap slots on errors#13634

Open
alexcrichton wants to merge 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-gc-slot-leak
Open

Fix leaking GC heap slots on errors#13634
alexcrichton wants to merge 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-gc-slot-leak

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit fixes a bugs Store::allocate_gc_store where a linear memory slot could be allocate but a failure allocating a GC heap slot would cause the linear memory to get leaked (not properly deallocated within the pooling allocator). The fix here is to juggle ownership slightly differently, notably deferring the attach operation to only after the GC heap is successfully allocated. This enables gracefully handling the error of allocating a GC heap and deallocating the memory.

This commit fixes a bugs `Store::allocate_gc_store` where a linear
memory slot could be allocate but a failure allocating a GC heap slot
would cause the linear memory to get leaked (not properly deallocated
within the pooling allocator). The fix here is to juggle ownership
slightly differently, notably deferring the `attach` operation to only
after the GC heap is successfully allocated. This enables gracefully
handling the error of allocating a GC heap and deallocating the memory.
@alexcrichton alexcrichton requested a review from a team as a code owner June 13, 2026 18:49
@alexcrichton alexcrichton requested review from pchickey and removed request for a team June 13, 2026 18:49
@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant