mirror of
https://github.com/golang/go
synced 2024-11-17 08:54:41 -07:00
internal/trace: fix race condition in gc-stress
Multiple goroutines all writing to the same sink triggers the race detector, rightfully so. Change-Id: Ia64836d0d88c0f587a6cb96ed747f656a3c1804a Reviewed-on: https://go-review.googlesource.com/c/go/+/562997 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
9fa153b729
commit
09c62a86a9
@ -39,7 +39,7 @@ func makeTree(depth int) *node {
|
||||
|
||||
var trees [16]*node
|
||||
var ballast *[16]*[8192]*node
|
||||
var sink []byte
|
||||
var sink [][]byte
|
||||
|
||||
func main() {
|
||||
for i := range trees {
|
||||
@ -54,10 +54,15 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := 0; i < runtime.GOMAXPROCS(-1); i++ {
|
||||
|
||||
procs := runtime.GOMAXPROCS(-1)
|
||||
sink = make([][]byte, procs)
|
||||
|
||||
for i := 0; i < procs; i++ {
|
||||
i := i
|
||||
go func() {
|
||||
for {
|
||||
sink = make([]byte, rand.Intn(32<<10))
|
||||
sink[i] = make([]byte, rand.Intn(32<<10))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user