fix: reclaim host stream/future transmits when the guest drops its end#13515
Open
gfx wants to merge 1 commit into
Open
fix: reclaim host stream/future transmits when the guest drops its end#13515gfx wants to merge 1 commit into
gfx wants to merge 1 commit into
Conversation
7025008 to
ac7f447
Compare
When the guest drops its end of a stream/future while the host consumer/producer is still `HostReady`, the host end was never finalized, so the `TransmitState` and both handles leaked from the concurrent-state table (eventually trapping with "resource table has no free keys"). The `HostReady` arms of `host_drop_reader` and `host_drop_writer` were no-ops; both now `delete_transmit`. `host_drop_writer` only finalizes once the writer is actually `Dropped`. Adds two `component-async-tests` regression tests (one per path) that fail on `main` and pass here. Fixes bytecodealliance#13514. Assisted-by: Claude Code
ac7f447 to
89cc10d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13514.
When the guest drops its end of a stream/future while the host consumer/producer is still
HostReady, the transmit was never reclaimed. This finalizes the stranded host end so theTransmitStateand both handles are freed.Fix
crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs— twoHostReadyarms were no-ops; both now calldelete_transmit(which also drops the host producer/consumer):host_drop_reader(guest dropped the read end → host producer): the read end is alreadyDropped, so finalize unconditionally.host_drop_writer(guest dropped the write end → host consumer): the write end isn't forcedDroppedhere, so finalize only once the writer is actually gone.Tests
Two regression tests in
component-async-tests, driving only the publicStreamReader::pipe/FutureReader::newAPIs:streams::async_host_consumer_drop(+ a minimalhost-consumer-drop-guesttest program) — covershost_drop_writer.streams::async_host_producer_drop(reuses the existingclosed-streamsguest) — covershost_drop_reader.Both fail on
main(leftover concurrent-state entries viaassert_concurrent_state_empty) and pass with this change.Verification
cargo test -p component-async-tests --test test_all→ 82 passed, 0 failed.