From ac32618dabc2109df9bf294e4b5fbd043ae5900f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 18 Nov 2026 16:01:41 -0700 Subject: [PATCH] make `during-sync-call-no-sibling-resume.wast` a bit more robust Previously, the second test in that file was overly sensitive to how the runtime might schedule consecutive host->guest calls and any threads they might spawn. Specifically, it assumed that, if the first of two calls does a `thread.resume-later`, the second call would run before that thread resumes. I don't believe there's anything in the spec that requires that behavior, and indeed I'm working on a Wasmtime patch which breaks that assumption. My solution is to refactor the test a bit so that there's only one host->guest call, and the rest is taken care of inside the guest. --- test/async/during-sync-call-no-sibling-resume.wast | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/async/during-sync-call-no-sibling-resume.wast b/test/async/during-sync-call-no-sibling-resume.wast index 26a3328ff..76460a477 100644 --- a/test/async/during-sync-call-no-sibling-resume.wast +++ b/test/async/during-sync-call-no-sibling-resume.wast @@ -161,17 +161,24 @@ ;; immediately rather than resume it. (component (component $Inner + (import "sibling" (instance $sibling + (export "arm" (func)) + )) (core module $Core (import "" "thread.suspend" (func $thread.suspend (result i32))) + (import "" "arm" (func $arm)) ;; non-async-typed: suspend with no thread of this instance to switch to (func (export "sync-block") + (call $arm) (drop (call $thread.suspend)) unreachable) ) (canon thread.suspend (core func $thread.suspend)) + (canon lower (func $sibling "arm") (core func $arm)) (core instance $core (instantiate $Core (with "" (instance (export "thread.suspend" (func $thread.suspend)) + (export "arm" (func $arm)) )))) (func (export "sync-block") (canon lift (core func $core "sync-block"))) @@ -206,10 +213,9 @@ (func (export "arm") (canon lift (core func $core "arm"))) ) - (instance $inner (instantiate $Inner)) (instance $sibling (instantiate $Sibling)) - (func (export "arm") (alias export $sibling "arm")) + (instance $inner (instantiate $Inner + (with "sibling" (instance $sibling)))) (func (export "sync-block") (alias export $inner "sync-block")) ) -(assert_return (invoke "arm")) (assert_trap (invoke "sync-block") "cannot block a synchronous task before returning")