From: Ian Lance Taylor Date: Mon, 26 Oct 2015 20:58:23 +0000 (-0700) Subject: cmd/compile: make sure instrumented call has type width X-Git-Tag: go1.6beta1~642 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9179c9cb5c369e075a65a2a5addd4a0e0b099b16;p=gostls13.git cmd/compile: make sure instrumented call has type width 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 TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- diff --git a/misc/cgo/testsanitizers/test.bash b/misc/cgo/testsanitizers/test.bash index 88c54e6173..19407b8cb2 100755 --- a/misc/cgo/testsanitizers/test.bash +++ b/misc/cgo/testsanitizers/test.bash @@ -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 diff --git a/src/cmd/compile/internal/gc/racewalk.go b/src/cmd/compile/internal/gc/racewalk.go index 7770f741df..acebb1ac9c 100644 --- a/src/cmd/compile/internal/gc/racewalk.go +++ b/src/cmd/compile/internal/gc/racewalk.go @@ -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 {