github-vet / github-vet/rangeloop-pointer-findings
gambol99/rbd-fence: pkg/aws/events.go; 27 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [gambol99/rbd-fence](https://www.github.com/gambol99/rbd-fence) at [pkg/aws/events.go](https://github.com/gambol99/rbd-fence/blob/623a9b73c3a7a17f6076e4143f4bab7404d0847c/pkg/aws/events.go#L139-L165)
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.
> function call which takes a reference to x at line 147 may start a goroutine
[Click here to see the code in its original context.](https://github.com/gambol99/rbd-fence/blob/623a9b73c3a7a17f6076e4143f4bab7404d0847c/pkg/aws/events.go#L139-L165)
Click here to show the 27 line(s) of Go which triggered the analyzer.
```go
for _, x := range runningNow {
// step: do we have a status for this instance in the cache or is it new?
instance, found := r.getStatus(x.InstanceId)
// the instance was not in the previous list - assuming it's new
if !found {
glog.V(2).Infof("Found a new instance: %s in the region, current status: %s", x.InstanceId, x.State.Name)
// step: send the event
r.sendEvent(&x, nil)
// step: add the instance to the cache
r.setStatus(x)
continue
}
// has the state of the instance changed from before?
if x.State.Name != instance.State.Name {
glog.V(3).Infof("Status change for instance: %s, from: %s to: %s", instance.InstanceId, instance.State.Name, x.State.Name)
// step: forward on the event
r.sendEvent(&instance, &x)
// step: update the instance in the cache
r.setStatus(x)
continue
}
// else the state of the instance has not changed
glog.V(5).Infof("The instance: %s status remains the same, current status: %s", x.InstanceId, x.State.Name)
}
```
Click here to show extra information the analyzer produced.
```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(sendEvent, 2)" -> {}
}
```
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: 623a9b73c3a7a17f6076e4143f4bab7404d0847c
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.