]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: avoid creating circular lists when compiling with race detector.
authorDaniel Morsing <daniel.morsing@gmail.com>
Tue, 11 Jun 2013 19:19:29 +0000 (21:19 +0200)
committerDaniel Morsing <daniel.morsing@gmail.com>
Tue, 11 Jun 2013 19:19:29 +0000 (21:19 +0200)
Fixes #5431.

R=dvyukov, remyoudompheng, rsc
CC=gobot, golang-dev
https://golang.org/cl/9910043

src/cmd/gc/racewalk.c
src/pkg/runtime/race/testdata/regression_test.go

index 8b644e7a45d7c338ab065f8b7c1b298ea1162074..60ed0f06438330776ac6ce08a4beb50c90fd59b3 100644 (file)
@@ -255,7 +255,11 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                // side effects are safe.
                // n->right may not be executed,
                // so instrumentation goes to n->right->ninit, not init.
-               l = nil;
+               // If right->ninit is non-nil, racewalknode might append it to itself.
+               // nil it out and handle it separately before putting it back.
+               l = n->right->ninit;
+               n->right->ninit = nil;
+               racewalklist(l, nil);
                racewalknode(&n->right, &l, wr, 0);
                appendinit(&n->right, l);
                goto ret;
index f08ee3ed31df7f1f886c6f664aeebeedf8aeb160..49e03d9082d76874ab36ed2019ff315d6cd92c89 100644 (file)
@@ -160,3 +160,18 @@ func noRaceReturn(c chan int) (a, b int) {
        }()
        return a, 10
 }
+
+func issue5431() {
+       var p **inltype
+       if inlinetest(p).x && inlinetest(p).y {
+       } else if inlinetest(p).x || inlinetest(p).y {
+       }
+}
+
+type inltype struct {
+       x, y bool
+}
+
+func inlinetest(p **inltype) *inltype {
+       return *p
+}