Commit 381b72a7 authored by Rémy Oudompheng's avatar Rémy Oudompheng

cmd/gc: cleanup SWITCH nodes after walk.

Keeping pointers from the pre-walk phase confuses
the race detection instrumentation.

Fixes #6418.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/13368057
parent d0bc227a
......@@ -820,6 +820,9 @@ walkswitch(Node *sw)
return;
}
exprswitch(sw);
// Discard old AST elements after a walk. They can confuse racewealk.
sw->ntest = nil;
sw->list = nil;
}
/*
......
......@@ -231,6 +231,22 @@ func TestRaceCaseFallthrough(t *testing.T) {
<-ch
}
func TestRaceCaseIssue6418(t *testing.T) {
m := map[string]map[string]string{
"a": map[string]string{
"b": "c",
},
}
ch := make(chan int)
go func() {
m["a"]["x"] = "y"
ch <- 1
}()
switch m["a"]["b"] {
}
<-ch
}
func TestRaceCaseType(t *testing.T) {
var x, y int
var i interface{} = x
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment