-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
Proposal Details
Reassignment of variables of type sync.WaitGroup is likely to cause bugs due to the potential to overwrite a WaitGroup with a non-zero counter value with a WaitGroup that has a zero counter. I can't think of any scenarios whereby reassigning a variable of type sync.WaitGroup would be required or useful. The waitgroup analysis pass should be extended to report reassignments of sync.WaitGroup variables.
Example
package main
import (
"sync"
)
type Object struct {
wg sync.WaitGroup
}
var wg0 sync.WaitGroup
func main() {
var wg1 sync.WaitGroup // ok
wg2 := sync.WaitGroup{} // ok
var wg3 sync.WaitGroup = sync.WaitGroup{} // ok
obj := Object{
wg: sync.WaitGroup{}, // ok
}
wg0 = sync.WaitGroup{} // want: variable of type sync.WaitGroup reassigned
wg1 = sync.WaitGroup{} // want: variable of type sync.WaitGroup reassigned
obj.wg = sync.WaitGroup{} // want: variable of type sync.WaitGroup reassigned
wg0.Wait()
wg1.Wait()
wg2.Wait()
wg3.Wait()
}Should this proposal be approved, I'd like to contribute the aforementioned changes.
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.