From 7736921401e29ae11df902654eb2530ba12097d3 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 28 Mar 2024 13:23:10 -0700 Subject: [PATCH] Report timeout in interpretation of AtomicWait To avoid slow-running fuzz cases, we report a host limit when interpreting atomic.wait with any non-zero timeout. However, in the allowed case where the timeout is zero, we were incorrectly interpreting the wait as returning 0, meaning that it was woken up, instead of 2, meaning that the timeout expired. Fix it to return 2. --- src/wasm-interpreter.h | 2 +- test/lit/exec/atomic.wast | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 377eb94652c..35fda991f21 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -3431,7 +3431,7 @@ class ModuleRunnerBase : public ExpressionRunner { if (timeout.getSingleValue().getInteger() != 0) { hostLimit("threads support"); } - return Literal(int32_t(0)); // equal + return Literal(int32_t(2)); // Timed out } Flow visitAtomicNotify(AtomicNotify* curr) { NOTE_ENTER("AtomicNotify"); diff --git a/test/lit/exec/atomic.wast b/test/lit/exec/atomic.wast index 73567121ff2..631bdd53174 100644 --- a/test/lit/exec/atomic.wast +++ b/test/lit/exec/atomic.wast @@ -8,7 +8,7 @@ (memory $0 23 256 shared) ;; CHECK: [fuzz-exec] calling wait_and_log - ;; CHECK-NEXT: [LoggingExternalInterface logging 0] + ;; CHECK-NEXT: [LoggingExternalInterface logging 2] (func $wait_and_log (export "wait_and_log") (call $log (memory.atomic.wait64