]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: call msanwrite on object passed to runtime/cgo
authorIan Lance Taylor <iant@golang.org>
Tue, 5 Jan 2016 22:06:58 +0000 (14:06 -0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 6 Jan 2016 04:04:42 +0000 (04:04 +0000)
Avoids an msan error when runtime/cgo is explicitly rebuilt with
-fsanitize=memory.

Fixes #13815.

Change-Id: I70308034011fb308b63585bcd40b0d1e62ec93ef
Reviewed-on: https://go-review.googlesource.com/18263
Reviewed-by: Russ Cox <rsc@golang.org>
misc/cgo/testsanitizers/test.bash
src/runtime/proc.go

index 269db2f3411dd282340c1248adffc33ad5850132..feacd89c279b6e4af80321a436f3f594d076f3b2 100755 (executable)
@@ -61,7 +61,12 @@ if ! go run -msan msan.go; then
   status=1
 fi
 
-if ! go run -msan msan2.go; then
+if ! CGO_LDFLAGS="-fsanitize=memory" CGO_CPPFLAGS="-fsanitize=memory" go run -msan -a msan2.go; then
+  echo "FAIL: msan2 with -fsanitize=memory"
+  status=1
+fi
+
+if ! go run -msan -a msan2.go; then
   echo "FAIL: msan2"
   status=1
 fi
index 3fa21d8e6fc54f7b30ebf5baec6b25fb4ff8c4e8..12fba1404c2f6dee02c040ec190b13b23b99814a 100644 (file)
@@ -1489,6 +1489,9 @@ func newm(fn func(), _p_ *p) {
                ts.g.set(mp.g0)
                ts.tls = (*uint64)(unsafe.Pointer(&mp.tls[0]))
                ts.fn = unsafe.Pointer(funcPC(mstart))
+               if msanenabled {
+                       msanwrite(unsafe.Pointer(&ts), unsafe.Sizeof(ts))
+               }
                asmcgocall(_cgo_thread_start, unsafe.Pointer(&ts))
                return
        }