Skip to content

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

Closed

Description

@koziy

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:

  1. $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.
  2. 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.
  3. 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?

Activity

  1. lukewagner commented on Nov 12, 2026

    @lukewagner
    Member

    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?

  2. alexcrichton commented on Nov 12, 2026

    @alexcrichton
    Collaborator

    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

  3. added a commit that references this issue on Nov 13, 2026
    d3ad5ca
  4. added a commit that references this issue on Nov 18, 2026
    9ff90fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions