-
Notifications
You must be signed in to change notification settings - Fork 64
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
pkg/pwalk: fix data race with err #109
Conversation
Go race detector found a race in the code wrt err read/write: > $ cd pkg/pwalk && go test -run Many -race . > === RUN TestWalkManyErrors > ================== > WARNING: DATA RACE > Read at 0x00c0000a0510 by goroutine 7: > github.com/opencontainers/selinux/pkg/pwalk.WalkN() > /home/kir/go/src/github.com/opencontainers/selinux/pkg/pwalk/pwalk.go:91 +0x1f8 > github.com/opencontainers/selinux/pkg/pwalk.Walk() > /home/kir/go/src/github.com/opencontainers/selinux/pkg/pwalk/pwalk.go:35 +0x321 > ... > Previous write at 0x00c0000a0510 by goroutine 8: > github.com/opencontainers/selinux/pkg/pwalk.WalkN.func1() > /home/kir/go/src/github.com/opencontainers/selinux/pkg/pwalk/pwalk.go:53 +0xa6 Indeed, we wait for all runner goroutines but do not wait for the filetree reading goroutine (the one that calls filepath.Walk). One way to fix it would be to not assign value to global variable err in the filetree reading goroutine, but do that in a runner. Unfortunately, that way we might mix up and not return the first error. Fix by using waitgroup for the reading goroutine as well. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
lgtm and verified locally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@thaJeztah you have to add the *which maybe we should ditch as we did in runc, opencontainers/runc#2388 |
ooooh, so it doesn't look at "reviews", only "comments"? |
oh, wow, that's "silly" |
Looks like there's support for github reviews in the v2 syntax that we're using (https://v2-docs.pullapprove.com/groups/github_reviews/), but v3 is the current version of the config format (not sure if that allows approval through comments), but yes, I think GitHub's native reviews should work fine for this |
except for people who use email to LGTM (I'm not sure we have anyone doing that in here) |
Fixes: #108
Go race detector found a race in the code wrt err read/write:
Indeed, we wait for all runner goroutines but do not wait for the
filetree reading goroutine (the one that calls filepath.Walk).
One way to fix it would be to not assign value to global variable err in
the filetree reading goroutine, but do that in a runner. Unfortunately,
that way we might mix up and not return the first error.
Fix by using waitgroup for the reading goroutine as well. Slightly
more complex than not assiging err in there, but guarantee we'll
return the first error.