4 ms·
Another error the author made is adding to a sync.WaitGroup in a different goroutine than the one that waits. This is another rookie mistake that go test -race
by intortus 12y ago
Another error the author made is adding to a sync.WaitGroup in a different goroutine than the one that waits. This is another rookie mistake that go test -race would probably catch.
- Strom 12y agoIndeed. Additionally, waitgroups aren't even needed, the channel usage in the code is already enough sync.
- Twirrim 12y agoIt does indeed catch it $ go test -race -bench=. ... WARNING: DATA RACE Write by goroutine 4: sync.raceWrite() /usr/lib/go/src/pkg/sync/race.go:41 +0x35 sync.(*WaitGroup).Wait() /usr/lib/go/src/pkg/sync/waitgroup.go:120 +0x16d _/home/twirrim/monte.GetPiMulti() /home/twirrim/monte/monte.go:56 +0x23a _/home/twirrim/monte.BenchmarkGetPiMulti() /home/twirrim/monte/monte_test.go:17 +0x62 testing.(*B).runN() /usr/lib/go/src/pkg/testing/benchmark.go:119 +0xc0 testing.(*B).launch() /usr/lib/go/src/pkg/testing/benchmark.go:207 +0x1ba ... And so on.
- soroushjp 12y agoFixed, thank you :)