]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: make sure instrumented call has type width
authorIan Lance Taylor <iant@golang.org>
Mon, 26 Oct 2015 20:58:23 +0000 (13:58 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 3 Nov 2015 23:42:06 +0000 (23:42 +0000)
The width of the type of an external variable defined with a type
literal may not be set when the instrumentation pass is run.  There are
two cases in the standard library that fail without the call to dowidth:

../../../src/encoding/base32/base32.go:322: constant -1000000000 overflows uintptr
../../../src/encoding/base32/base32.go:329: constant -1000000000 overflows uintptr
../../../src/encoding/json/encode.go:385: constant -1000000000 overflows uintptr
../../../src/encoding/json/encode.go:387: constant -1000000000 overflows uintptr

Change-Id: I7c3334f7decdb7488595ffe4090cd262d7334283
Reviewed-on: https://go-review.googlesource.com/16331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
misc/cgo/testsanitizers/test.bash
src/cmd/compile/internal/gc/racewalk.go

index 88c54e61732b6e6d3bc9b6071fe6dd073e115c2e..19407b8cb288d7e87a27cef82054630e146278b3 100755 (executable)
@@ -37,6 +37,11 @@ fi
 
 status=0
 
+if ! go build -msan std; then
+  echo "FAIL: build -msan std"
+  status=1
+fi
+
 if ! go run -msan msan.go; then
   echo "FAIL: msan"
   status=1
index 7770f741df71720e7a39a340f1a15f19de281519..acebb1ac9ca1416bacf67d478bf2b956643f1be6 100644 (file)
@@ -502,13 +502,25 @@ func callinstr(np **Node, init **NodeList, wr int, skip int) bool {
                        if wr != 0 {
                                name = "msanwrite"
                        }
-                       f = mkcall(name, nil, init, uintptraddr(n), Nodintconst(t.Width))
+                       // dowidth may not have been called for PEXTERN.
+                       dowidth(t)
+                       w := t.Width
+                       if w == BADWIDTH {
+                               Fatalf("instrument: %v badwidth", t)
+                       }
+                       f = mkcall(name, nil, init, uintptraddr(n), Nodintconst(w))
                } else if flag_race != 0 && (t.Etype == TSTRUCT || Isfixedarray(t)) {
                        name := "racereadrange"
                        if wr != 0 {
                                name = "racewriterange"
                        }
-                       f = mkcall(name, nil, init, uintptraddr(n), Nodintconst(t.Width))
+                       // dowidth may not have been called for PEXTERN.
+                       dowidth(t)
+                       w := t.Width
+                       if w == BADWIDTH {
+                               Fatalf("instrument: %v badwidth", t)
+                       }
+                       f = mkcall(name, nil, init, uintptraddr(n), Nodintconst(w))
                } else if flag_race != 0 {
                        name := "raceread"
                        if wr != 0 {