github-vet / github-vet/rangeloop-pointer-findings
rododo-meow/CUBE: src/CUBE/update.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [rododo-meow/CUBE](https://www.github.com/rododo-meow/CUBE) at [src/CUBE/update.go](https://github.com/rododo-meow/CUBE/blob/2d7cb034733e1a34277cec3c431b1c126b2ba73e/src/CUBE/update.go#L6-L55)
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 eid used in defer or goroutine at line 21
[Click here to see the code in its original context.](https://github.com/rododo-meow/CUBE/blob/2d7cb034733e1a34277cec3c431b1c126b2ba73e/src/CUBE/update.go#L6-L55)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for eid, e := range worker.edges {
if e.mirror {
continue
}
var wg sync.WaitGroup
wg.Add(worker.cube.L - 1)
var colle []Data
if cmd.localCombiner != nil {
colle = make([]Data, worker.cube.L)
colle[0] = cmd.localCombiner(e.data.Share, e.data.Colle)
for i := 1; i < worker.cube.L; i++ {
go func(i int) {
defer wg.Done()
resp := make(chan []Data)
worker.cube.SendInternal(worker.node + i * worker.cube.NperL,
CmdFetchEdge{eid: eid, resp: resp, localCombiner: cmd.localCombiner})
tmp := <-resp
colle[i] = tmp[0]
}(i)
}
} else {
colle = make([]Data, worker.cube.Sc)
copy(colle, e.data.Colle)
for i := 1; i < worker.cube.L; i++ {
go func(i int) {
defer wg.Done()
resp := make(chan []Data)
worker.cube.SendInternal(worker.node + i * worker.cube.NperL,
CmdFetchEdge{eid: eid, resp: resp, localCombiner: nil})
tmp := <-resp
copy(colle[worker.cube.LowerBound(i):], tmp)
}(i)
}
}
wg.Wait()
newedge := cmd.f(e.data.Share, colle)
if cmd.localCombiner != nil {
worker.edges[eid].data.Share = newedge.Share
for i := 1; i < worker.cube.L; i++ {
worker.cube.SendInternal(worker.node + i * worker.cube.NperL,
CmdPushEdgeShare{eid: eid, data: newedge.Share})
}
} else {
worker.edges[eid].data = worker.cube.SplitEdgeData(newedge, 0)
for i := 1; i < worker.cube.L; i++ {
worker.cube.SendInternal(worker.node + i * worker.cube.NperL,
CmdPushEdge{eid: eid, data: newedge})
}
}
}
```
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: 2d7cb034733e1a34277cec3c431b1c126b2ba73e
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.