You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
during-sync-call-exclusive-resume.wast:169 expects the no-ready-thread trap, but the reference traps first at the callback task's unresolved exit #763
Repro: test/async/during-sync-call-exclusive-resume.wast:169 at 6250899 (the file's third component, added by #761).
Trace through design/mvp/canonical-abi/definitions.py at 6250899:
$D's sync run calls $C's arm (async-typed, callback ABI, lowered async). arm returns YIELD without calling task.return. The callback loop (canon_lift, 2142–2151) parks its implicit thread in wait_until(lambda: inst.exclusive_thread is None), where it stays ready.
run calls $C's sync-typed sync-block, which calls thread.suspend. canon_lift's sync wait loop (2175–2177) finds arm's thread among the ready candidates and resumes it.
exit-cb returns EXIT. task.exit_implicit_thread() (2168) → unregister_thread (458–462): the task's last thread leaves while state != RESOLVED, so trap_if(self.state != Task.State.RESOLVED) traps. cont_new/resume (229–255) re-raise that trap out of the sync loop.
So the loop's own trap_if(not candidates) is never reached. That is the trap CanonicalABI.md:3614–3617 describes: a non-async-typed call blocks before returning and no other thread is ready.
The suite expects (assert_trap (invoke "run") "cannot block a synchronous task before returning"). Those are the words for that unreached trap, as at :103, where the callback task did resolve. wasmtime 50.0.1 passes the file.
Which trap is intended here: the unresolved exit (CanonicalABI.md:735–740), as the reference specifies, or the no-ready-thread trap the assertion names? If it is the former, should :169 expect different words?
Great catch and thanks for reporting! Probably the right fix is:
-(assert_trap (invoke "run") "cannot block a synchronous task before returning")+(assert_trap (invoke "run") "async-lifted export failed to produce a result")
and Wasmtime would need to rearrange the order of checks in its thread exit logic so that the latter error message is generated first.
Incidentally, one change that was motivated by and included in #730, but I think makes sense independently, is to remove this special "no threads left in the task" trap entirely (so that when you hit this case, instead of trapping, it works the same way as if a thread is permanently suspended: eventually you may hit the "no threads left to run" trapping condition. I think this relaxation makes sense b/c there's nothing special about this trivial case of deadlock and ruling it out doesn't really provide any guarantees. Also, it might remove an extra bit of state (the per-task thread count) that the runtime has to maintain. If we went with this "fix", this test would stay the same and I could write some new tests. @alexcrichton@dicej WDYT?
Activity
lukewagner commentedon Nov 12, 2026
Great catch and thanks for reporting! Probably the right fix is:
and Wasmtime would need to rearrange the order of checks in its thread exit logic so that the latter error message is generated first.
Incidentally, one change that was motivated by and included in #730, but I think makes sense independently, is to remove this special "no threads left in the task" trap entirely (so that when you hit this case, instead of trapping, it works the same way as if a thread is permanently suspended: eventually you may hit the "no threads left to run" trapping condition. I think this relaxation makes sense b/c there's nothing special about this trivial case of deadlock and ruling it out doesn't really provide any guarantees. Also, it might remove an extra bit of state (the per-task thread count) that the runtime has to maintain. If we went with this "fix", this test would stay the same and I could write some new tests. @alexcrichton @dicej WDYT?
alexcrichton commentedon Nov 12, 2026
That sounds reasonable to me yeah. I'm not certain it'd be able to remove state, but I agree conceptually it's a desirable change to make
CABI: don't trap if the last thread of a task exits before the task i…
CABI: don't trap if the last thread of a task exits before the task i…