]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix handling of for post-condition in -race mode
authorRuss Cox <rsc@golang.org>
Sat, 31 May 2014 13:35:54 +0000 (09:35 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 31 May 2014 13:35:54 +0000 (09:35 -0400)
Fixes #8102.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/100870046

src/cmd/gc/racewalk.c
src/pkg/runtime/race/race_test.go

index 2319d7f64281216f9a9facbd8eb866fc3f8486ad..285bd78a258ac63715d9892ea66992bf2d4343a7 100644 (file)
@@ -182,7 +182,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                        // x, y := f() becomes BLOCK{CALL f, AS x [SP+0], AS y [SP+n]}
                        // We don't want to instrument between the statements because it will
                        // smash the results.
-                       racewalknode(&n->list->n, &n->ninit, 0, 0);
+                       racewalknode(&n->list->n, &n->list->n->ninit, 0, 0);
                        fini = nil;
                        racewalklist(n->list->next, &fini);
                        n->list = concat(n->list, fini);
index 88ef89d82ad2ea37045d4294544652df2ceebe6e..7e0ee866a630b3178a7f78b5bb4d201ff3cab57e 100644 (file)
@@ -155,3 +155,18 @@ func runTests() ([]byte, error) {
        cmd.Env = append(cmd.Env, `GORACE="suppress_equal_stacks=0 suppress_equal_addresses=0 exitcode=0"`)
        return cmd.CombinedOutput()
 }
+
+func TestIssue8102(t *testing.T) {
+       // If this compiles with -race, the test passes.
+       type S struct {
+               x interface{}
+               i int
+       }
+       c := make(chan int)
+       a := [2]*int{}
+       for ; ; c <- *a[S{}.i] {
+               if t != nil {
+                       break
+               }
+       }
+}