github-vet / github-vet/rangeloop-pointer-findings
tinytub/zep-cli: exporter/collectors/collector.go; 41 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [tinytub/zep-cli](https://www.github.com/tinytub/zep-cli) at [exporter/collectors/collector.go](https://github.com/tinytub/zep-cli/blob/14b6a76769539cd780e08840bf8326bdedcebe45/exporter/collectors/collector.go#L183-L223)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable tablename used in defer or goroutine at line 193
[Click here to see the code in its original context.](https://github.com/tinytub/zep-cli/blob/14b6a76769539cd780e08840bf8326bdedcebe45/exporter/collectors/collector.go#L183-L223)
Click here to show the 41 line(s) of Go which triggered the analyzer.
```go
for _, tablename := range tablelist.Name {
go func(tablename string) {
ptable, _ := zeppelin.PullTable(tablename, c.addrs)
wg.Add(1)
used, remain, _ := ptable.Space(tablename, c.addrs)
c.TableUsed.WithLabelValues(tablename).Set(float64(used))
c.TableRemain.WithLabelValues(tablename).Set(float64(remain))
wg.Done()
}(tablename)
go func() {
ptable, _ := zeppelin.PullTable(tablename, c.addrs)
tableEpoch := ptable.TableEpoch
c.Epoch.WithLabelValues("table", tablename, "").Set(float64(tableEpoch))
wg.Add(1)
nodeEpoch, _ := ptable.Server(c.addrs)
for _, e := range nodeEpoch {
c.Epoch.WithLabelValues("node", "", e.Addr).Set(float64(e.Epoch))
}
wg.Done()
}()
go func(tablename string) {
ptable, _ := zeppelin.PullTable(tablename, c.addrs)
wg.Add(1)
query, qps, _ := ptable.Stats(tablename, c.addrs)
c.TableQuery.WithLabelValues(tablename).Set(float64(query))
c.TableQPS.WithLabelValues(tablename).Set(float64(qps))
wg.Done()
}(tablename)
go func(tablename string) {
ptable, _ := zeppelin.PullTable(tablename, c.addrs)
wg.Add(1)
Offset, _ := ptable.Offset(tablename, c.addrs)
for pid, slave := range Offset {
for _, offset := range slave {
c.TableOffset.WithLabelValues(tablename, strconv.Itoa(int(pid)), offset.Addr).Set(offset.Offset)
}
}
wg.Done()
}(tablename)
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 14b6a76769539cd780e08840bf8326bdedcebe45
Contributor guide
No contributing guide indexed for this repository
Research direction
Read exporter/collectors/collector.go lines 183-223 and compare the goroutines that pass tablename explicitly with the one that closes over it. Confirm whether the captured range variable can vary across goroutines; done means choosing Bug, Mitigated, or Desirable Behavior and leaving the corresponding reaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 40/100