GamePad64 opened PR #15200 from GamePad64:fix/concurrent-defer-caller-completion to bytecodealliance:main:
Found in the wild: a Servo-based renderer component (web page →
markdown) running ~15 cooperative guest threads under wasip3, driven by
repeated calls into one component instance. Within ten cold runs the
second call into the instance stopped returning.Two scheduler defects, two commits. They manifest the same way (the
instance'sdo_not_enterlatch stays set and every later call is
refused) but have independent triggers. Both were found and verified on
v50.0.1, whereconcurrent.rsstill lived atsrc/runtime/component/;
this PR is hand-ported to main, where the file is
crates/wasmtime/src/runtime/component/concurrent.rs
GamePad64 removed the review request for wasmtime-core-reviewers from PR #15200.
GamePad64 requested pchickey for a review on PR #15200.
GamePad64 requested wasmtime-core-reviewers for a review on PR #15200.
GamePad64 updated PR #15200.
GamePad64 updated PR #15200.
GamePad64 edited PR #15200:
Found in the wild: a Servo-based renderer component (web page → markdown) running ~15 cooperative guest threads under wasip3, driven by repeated calls into one component instance. Within ten cold runs the second call into the instance stopped returning: the instance's
do_not_enterlatch stayed set and every later call was refused. Two scheduler defects with independent triggers, two commits.Commit 1 —
poll_untilcompleted the caller future as soon as it polledReady, even with work items queued and in-flight ack tasks unpolled. The caller returns, the ack task never gets polled, the guest fiber never resumes,exit_instancenever runs. Now the caller future is polled at most once per pass; if it's ready while a switch item or high-priority work is pending, completion is deferred until the urgent queues are empty andConcurrentState::futureshas fully drained.Commit 2 — a task returning
Exitleaves staleResumeThread/GuestCallitems in the queues and switch slots; resuming one runs guest code past the task's end and strands a fiber onthread.suspend. On exit, both queues are retain-filtered and the switch slots cleared, scoped to the exiting thread — a task can have sibling threads still live (e.g. athread.newchild that hasn't run yet), and purging the whole task's items deadlocks the event loop waiting for atask.returnthat never happens.ResumeFiberitems are left alone: dropping a never-startedStoreFiberviaretainwould trip thedisposeassertion inDrop.Both fixes were found and verified on v50.0.1 and hand-ported to main (the file moved from
src/runtime/component/tocrates/wasmtime/src/runtime/component/). Commit 2's scope was corrected from task to thread aftertask-deletion.wastcaught it in CI.Testing: with both fixes, sequential second calls into one instance complete; a full render matrix and 10x single-call runs are green through a real host runtime. Before, the second call wedged within ten runs. No test added to the suite: the trigger needs a ~160 MB component; happy to shrink it with guidance.
@alexcrichton
github-actions[bot] added the label wasmtime:api on PR #15200.
alexcrichton removed the review request for pchickey from PR #15200.
alexcrichton requested alexcrichton for a review on PR #15200.
alexcrichton commented on PR #15200:
A few requests for this:
- Can you be sure to add tests for behavioral changes here?
- Can you clarify what's going on w.r.t. realease branches and main? The
mainbranch has a pretty enormous number of fixes relative to 50.0.x, so if 50.0.x has an issue it makes sense to fix, but did you testmainfirst before implementing/forward-porting fixes?For the first issue I think we've got a few possibly related issues to
poll_untiland starvation of other things in the event loop, so I'd ideally want to spend a bit more time thinking about that. Would it make sense to split apart the two issues being fixed here into two separate PRs?
Last updated: Nov 19 2026 at 20:05 UTC