-
Notifications
You must be signed in to change notification settings - Fork 18k
vet: copylock check doesn't detect certain copies #14664
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
Comments
Submitted a patch for code review - https://go-review.googlesource.com/20254 . |
CL https://golang.org/cl/20254 mentions this issue. |
Added yet another patch for detecting locks' copying inside composite literals: type A struct {
L sync.Mutex
}
var m sync.Mutex
a := A{
L: m, // now this case is detected
}
b := []sync.Mutex{m, a.L} // and this one
c := map[string]sync.Mutex{"foo": m} // and this one |
CL https://golang.org/cl/20258 mentions this issue. |
Thanks for working on these. I left some comments and asked Rob to take over reviewing once they're addressed (that's what R=r means). |
@josharain, I updated the CL according to comments. |
Please ping the CL. (Just write a comment that says "Ping.") Feel free to repeat as needed. I'm leaving the remainder of the review to Rob. |
There is yet another case not covered by var a [5]sync.Mutex
b := a // here we copy mutexes by value Will create a CL for this case. |
See the CL |
Yet another case has been caught and covered by the CL mentioned above: a := sync.Mutex{}
a = sync.Mutex{} // here a is overwritten by new value |
Updates #14664 Change-Id: I1f7b1116cfe91466816c760f136ce566da3e80a9 Reviewed-on: https://go-review.googlesource.com/24340 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
CL https://golang.org/cl/34630 mentions this issue. |
This is a follow-up for https://golang.org/cl/24340. Updates #14664. Fixes #18374. Change-Id: I2831556a9014d30ec70d5f91943d18c33db5b390 Reviewed-on: https://go-review.googlesource.com/34630 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
copylock check must emit a warning on copying
sync.Mutex
or struct containingsync.Mutex
. It doesn't detect the following cases:See #8005 for details.
The text was updated successfully, but these errors were encountered: