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
Research direction
Read src/CUBE/update.go around lines 6-55, starting at the range over worker.edges and the two goroutines that send CmdFetchEdge. Confirm the range-loop capture is safe in both branches and that eid remains correct for each response; done means the reported analyzer finding is resolved without changing edge-update behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100