New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
golang.org/x/sync/errgroup: strange data race #65045
Comments
Your Race is correct here, I don't get why this is supposed to work. |
A minified version of your code is this: var wg sync.WaitGroup
const n = 100
wg.Add(n)
var sink int
for range n {
go func() {
defer wg.Done()
sink = 42
}()
}
wg.Wait()
return sink |
Agreed — the race detector is correctly describing a race in the user code. (And the race has ~nothing to do with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go version
go version go1.21.6 linux/amd64
Output of
go env
in your module/workspace:What did you do?
data_race_test.go
:What did you see happen?
Run
go test -v -race data_race_test.go -run TestPanic
:Run
go test -v -race data_race_test.go -run TestNoPanic
:What did you expect to see?
Run
go test -v -race data_race_test.go -run TestPanic
:Run
go test -v -race data_race_test.go -run TestNoPanic
:The text was updated successfully, but these errors were encountered: