-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Milestone
Description
go version go1.2.1 linux/amd64
The race detector (go test -v -race) reports line numbers that are off-by-one in at
least one instance. The race below is on err, not on w, but the race is reported at the
line (***).
// begin snippet
nwork := 10
wks := make([]<-chan bool, nwork) // a slice to store workers in.
for i := 0; i < nwork; i++ {
w := HelperNewWorkerMonitored(cfg) // returns a new Worker every time
afterSend, afterReply := w.NS.MonitorSend, w.NR.MonitorRecv
wks[i] = afterReply
go func(w *Worker) {
_, err = w.DoOneJob() // the race is on err here
w.Destroy() // but go test -race reports race on this line (***)
}(w)
<-afterSend
}