From aa49a0b37249fc1d4a7963b6f1119983eaae9f97 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 22 Aug 2020 18:21:14 +0700 Subject: [PATCH] runtime: add test for StorepNoWB param leaking CL 249962 added wasm StorepNoWB implementation in assembly, it's now like all other architectures. This CL adds a general test that the second param of StorepNoWB must be force to escape. Fixes #40975 Change-Id: I1eccc7e50a3ec742a1912d65f25b15f9f5ad9241 Reviewed-on: https://go-review.googlesource.com/c/go/+/249761 Run-TryBot: Cuong Manh Le TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- src/runtime/internal/atomic/atomic_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/runtime/internal/atomic/atomic_test.go b/src/runtime/internal/atomic/atomic_test.go index 0c1125c558..b0a8fa0610 100644 --- a/src/runtime/internal/atomic/atomic_test.go +++ b/src/runtime/internal/atomic/atomic_test.go @@ -220,3 +220,13 @@ func TestBitwiseContended(t *testing.T) { } } } + +func TestStorepNoWB(t *testing.T) { + var p [2]*int + for i := range p { + atomic.StorepNoWB(unsafe.Pointer(&p[i]), unsafe.Pointer(new(int))) + } + if p[0] == p[1] { + t.Error("Bad escape analysis of StorepNoWB") + } +} -- 2.50.0