From: Daniel Martí Date: Tue, 21 Aug 2018 09:26:45 +0000 (+0100) Subject: cmd/compile: fix racy setting of gc's Config.Race X-Git-Tag: go1.12beta1~1375 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c1807989563e0bafc14c56dba3eb405a099f4495;p=gostls13.git cmd/compile: fix racy setting of gc's Config.Race ssaConfig.Race was being set by many goroutines concurrently, resulting in a data race seen below. This was very likely introduced by CL 121235. WARNING: DATA RACE Write at 0x00c000344408 by goroutine 12: cmd/compile/internal/gc.buildssa() /workdir/go/src/cmd/compile/internal/gc/ssa.go:134 +0x7a8 cmd/compile/internal/gc.compileSSA() /workdir/go/src/cmd/compile/internal/gc/pgen.go:259 +0x5d cmd/compile/internal/gc.compileFunctions.func2() /workdir/go/src/cmd/compile/internal/gc/pgen.go:323 +0x5a Previous write at 0x00c000344408 by goroutine 11: cmd/compile/internal/gc.buildssa() /workdir/go/src/cmd/compile/internal/gc/ssa.go:134 +0x7a8 cmd/compile/internal/gc.compileSSA() /workdir/go/src/cmd/compile/internal/gc/pgen.go:259 +0x5d cmd/compile/internal/gc.compileFunctions.func2() /workdir/go/src/cmd/compile/internal/gc/pgen.go:323 +0x5a Goroutine 12 (running) created at: cmd/compile/internal/gc.compileFunctions() /workdir/go/src/cmd/compile/internal/gc/pgen.go:321 +0x39b cmd/compile/internal/gc.Main() /workdir/go/src/cmd/compile/internal/gc/main.go:651 +0x437d main.main() /workdir/go/src/cmd/compile/main.go:51 +0x100 Goroutine 11 (running) created at: cmd/compile/internal/gc.compileFunctions() /workdir/go/src/cmd/compile/internal/gc/pgen.go:321 +0x39b cmd/compile/internal/gc.Main() /workdir/go/src/cmd/compile/internal/gc/main.go:651 +0x437d main.main() /workdir/go/src/cmd/compile/main.go:51 +0x100 Instead, set up the field exactly once as part of initssaconfig. Change-Id: I2c30c6b1cf92b8fd98e7cb5c2e10c526467d0b0a Reviewed-on: https://go-review.googlesource.com/130375 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Dave Cheney --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 199e4d9072..7b254698b7 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -49,6 +49,7 @@ func initssaconfig() { ssaConfig.Set387(thearch.Use387) } ssaConfig.SoftFloat = thearch.SoftFloat + ssaConfig.Race = flag_race ssaCaches = make([]ssa.Cache, nBackendWorkers) // Set up some runtime functions we'll need to call. @@ -131,7 +132,6 @@ func buildssa(fn *Node, worker int) *ssa.Func { s.f.Cache = &ssaCaches[worker] s.f.Cache.Reset() s.f.DebugTest = s.f.DebugHashMatch("GOSSAHASH", name) - s.f.Config.Race = flag_race s.f.Name = name if fn.Func.Pragma&Nosplit != 0 { s.f.NoSplit = true