]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add test for StorepNoWB param leaking
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 22 Aug 2020 11:21:14 +0000 (18:21 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 24 Aug 2020 03:55:18 +0000 (03:55 +0000)
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 <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/runtime/internal/atomic/atomic_test.go

index 0c1125c55831b663f29c278fbff532a22ce8c75d..b0a8fa06103ff2bf5e6c0c694e67d5e1190b08a9 100644 (file)
@@ -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")
+       }
+}