]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add instrumentation of OKEY
authorDmitry Vyukov <dvyukov@google.com>
Wed, 24 Jun 2015 17:25:51 +0000 (19:25 +0200)
committerRuss Cox <rsc@golang.org>
Fri, 26 Jun 2015 15:54:03 +0000 (15:54 +0000)
Instrument operands of OKEY.
Also instrument OSLICESTR. Previously it was not needed
because of preceeding bounds checks (which were instrumented).
But the preceeding bounds checks have disappeared.

Change-Id: I3b0de213e23cbcf5b8ef800abeded5eeeb3f8287
Reviewed-on: https://go-review.googlesource.com/11417
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/racewalk.go
src/runtime/race/testdata/slice_test.go

index f82609733d2365e876e08ffb1c4a821d7751c62b..2664e0cd6d839f74ad62d10e690caf6585b8e06c 100644 (file)
@@ -299,8 +299,14 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
                }
                goto ret
 
-       case OSLICE, OSLICEARR, OSLICE3, OSLICE3ARR:
+       case OSLICE, OSLICEARR, OSLICE3, OSLICE3ARR, OSLICESTR:
                racewalknode(&n.Left, init, 0, 0)
+               racewalknode(&n.Right, init, 0, 0)
+               goto ret
+
+       case OKEY:
+               racewalknode(&n.Left, init, 0, 0)
+               racewalknode(&n.Right, init, 0, 0)
                goto ret
 
        case OADDR:
@@ -413,8 +419,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
                OTYPE,
                ONONAME,
                OLITERAL,
-               OSLICESTR, // always preceded by bounds checking, avoid double instrumentation.
-               OTYPESW:   // ignored by code generation, do not instrument.
+               OTYPESW: // ignored by code generation, do not instrument.
                goto ret
        }
 
index 32ae87897008a6c3aeefac794a623db85a473d54..1ec52438ec498f73314d67d74f8e3a4506c6e5e3 100644 (file)
@@ -578,3 +578,15 @@ func TestRaceCompareString(t *testing.T) {
        s1 = s2
        <-c
 }
+
+func TestRaceSlice3(t *testing.T) {
+       done := make(chan bool)
+       x := make([]int, 10)
+       i := 2
+       go func() {
+               i = 3
+               done <- true
+       }()
+       _ = x[:1:i]
+       <-done
+}