From eb14b51c7e2647acb906cb2cfdee01d7308ac7de Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 19 Mar 2026 08:48:23 -0700 Subject: [PATCH] go --- src/wasm-interpreter.h | 3 +++ test/lit/exec/atomic.wast | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index d7dae5c59ab..6b9586b74c6 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -4213,6 +4213,9 @@ class ModuleRunnerBase : public ExpressionRunner { VISIT(timeout, curr->timeout) auto bytes = curr->expectedType.getByteSize(); auto info = getMemoryInstanceInfo(curr->memory); + if (!info.instance->wasm.getMemory(info.name)->shared) { + trap("cannot atomic.wait a non-shared memory"); + } auto memorySizeBytes = info.instance->getMemorySizeBytes(info.name); auto addr = info.instance->getFinalAddress( curr, ptr.getSingleValue(), bytes, memorySizeBytes); diff --git a/test/lit/exec/atomic.wast b/test/lit/exec/atomic.wast index 771d0c691ff..9e509e0bf06 100644 --- a/test/lit/exec/atomic.wast +++ b/test/lit/exec/atomic.wast @@ -5,17 +5,31 @@ (module (import "fuzzing-support" "log-i32" (func $log (param i32))) - (memory $0 23 256 shared) + (memory $shared 23 256 shared) + (memory $unshared 10 20) ;; CHECK: [fuzz-exec] export wait_and_log ;; CHECK-NEXT: [LoggingExternalInterface logging 2] (func $wait_and_log (export "wait_and_log") (call $log - (memory.atomic.wait64 + (memory.atomic.wait64 $shared (i32.const 0) (i64.const 0) (i64.const 0) ) ) ) + + ;; CHECK: [fuzz-exec] export wait_unshared + ;; CHECK-NEXT: [trap cannot atomic.wait a non-shared memory] + (func $wait_unshared (export "wait_unshared") + ;; Waiting on an unshared memory traps. + (drop + (memory.atomic.wait32 $unshared + (i32.const 0) + (i32.const 0) + (i64.const 0) + ) + ) + ) )