github-vet / github-vet/rangeloop-pointer-findings
kubeedge/examples: kubeedge-counter-demo/vendor/github.com/kubeedge/kubeedge/edge/pkg/edged/pleg/generic.go; 19 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kubeedge/examples](https://www.github.com/kubeedge/examples) at [kubeedge-counter-demo/vendor/github.com/kubeedge/kubeedge/edge/pkg/edged/pleg/generic.go](https://github.com/kubeedge/examples/blob/cc38a1a06c71de7390a77b445ae13e2f71dffa42/kubeedge-counter-demo/vendor/github.com/kubeedge/kubeedge/edge/pkg/edged/pleg/generic.go#L251-L269)
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.
>
[Click here to see the code in its original context.](https://github.com/kubeedge/examples/blob/cc38a1a06c71de7390a77b445ae13e2f71dffa42/kubeedge-counter-demo/vendor/github.com/kubeedge/kubeedge/edge/pkg/edged/pleg/generic.go#L251-L269)
Click here to show the 19 line(s) of Go which triggered the analyzer.
```go
for _, container := range containers {
if isInitContainer {
// If the init container is terminated with exit code 0, it won't be restarted.
// TODO(random-liu): Handle this in a cleaner way.
s := podStatus.FindContainerStatusByName(container.Name)
if s != nil && s.State == kubecontainer.ContainerStateExited && s.ExitCode == 0 {
continue
}
}
// If a container should be restarted in next syncpod, it is *Waiting*.
if !kubecontainer.ShouldContainerBeRestarted(&container, pod, podStatus) {
continue
}
cstatus := statuses[container.Name]
if cstatus.State.Terminated != nil {
cstatus.LastTerminationState = cstatus.State
}
statuses[container.Name] = cstatus
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {ShouldContainerBeRestarted 3} was not found in the callgraph; reference was passed directly to third-party code
```
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: cc38a1a06c71de7390a77b445ae13e2f71dffa42
Contributor guide
No contributing guide indexed for this repository
Research direction
Read kubeedge-counter-demo/vendor/github.com/kubeedge/kubeedge/edge/pkg/edged/pleg/generic.go around lines 251-269, then inspect the referenced ShouldContainerBeRestarted call. Determine whether the range-loop reference can cause an actual issue in this path; done means classifying the finding as Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100