Synchronize with destroying spawned tasks more in wasip2 - #14266
Merged
alexcrichton merged 1 commit intoSep 2, 2026
Conversation
alexcrichton
requested review from
pchickey and
rvolosatovs
and removed request for
a team
September 1, 2026 23:59
rvolosatovs
approved these changes
Sep 2, 2026
rvolosatovs
left a comment
Member
There was a problem hiding this comment.
Looks good to me, however it looks like the ip-name-lookup will need a sync module added for p2
alexcrichton
enabled auto-merge
September 2, 2026 16:06
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Sep 2, 2026
This commit fixes a test failure I'm running into in wasi-libc development where spawned tasks for wasip2 are keeping objects alive in a race condition where sometimes the task is torn down and sometimes it's not. Specifically wasip2 is built on wasip3-style primitives for UDP/TCP which means that futures are used, and if futures aren't immediately ready they're resolved in a spawned Tokio task. This spawned task can interact with UDP, for example, where exclusivity of a UDP socket is tested via `Arc::get_mut` which will nondeterministically return true or false depending if a previously spawned task has exited or not. In wasi-libc this means that reconnecting a UDP socket sometimes fails and sometimes passes because the background task may or may not have exited. Here this is resolved by making the `drop` methods async and then hooking into the preexisting `cancel` method which aborts the task and then waits on the result. This synchronizes with the task to ensure that the state of the socket is guaranteed to be exclusive after a disconnect and ready for another connect. This similar fix is then applied to ip-name-lookup as well.
alexcrichton
force-pushed
the
synchronize-more-tasks
branch
from
September 2, 2026 18:02
667f5c7 to
cfbaf82
Compare
alexcrichton
enabled auto-merge
September 2, 2026 18:02
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.
This commit fixes a test failure I'm running into in wasi-libc development where spawned tasks for wasip2 are keeping objects alive in a race condition where sometimes the task is torn down and sometimes it's not. Specifically wasip2 is built on wasip3-style primitives for UDP/TCP which means that futures are used, and if futures aren't immediately ready they're resolved in a spawned Tokio task. This spawned task can interact with UDP, for example, where exclusivity of a UDP socket is tested via
Arc::get_mutwhich will nondeterministically return true or false depending if a previously spawned task has exited or not. In wasi-libc this means that reconnecting a UDP socket sometimes fails and sometimes passes because the background task may or may not have exited.Here this is resolved by making the
dropmethods async and then hooking into the preexistingcancelmethod which aborts the task and then waits on the result. This synchronizes with the task to ensure that the state of the socket is guaranteed to be exclusive after a disconnect and ready for another connect. This similar fix is then applied to ip-name-lookup as well.