github-vet / github-vet/rangeloop-pointer-findings
shahar-klein/nv-ovn-k8s: go-controller/pkg/cluster/master.go; 3 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [shahar-klein/nv-ovn-k8s](https://www.github.com/shahar-klein/nv-ovn-k8s) at [go-controller/pkg/cluster/master.go](https://github.com/shahar-klein/nv-ovn-k8s/blob/fd18dd0bebcddcead0778dcfa1c25704708d04bb/go-controller/pkg/cluster/master.go#L153-L155)
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 policy at line 154 may start a goroutine
[Click here to see the code in its original context.](https://github.com/shahar-klein/nv-ovn-k8s/blob/fd18dd0bebcddcead0778dcfa1c25704708d04bb/go-controller/pkg/cluster/master.go#L153-L155)
Click here to show the 3 line(s) of Go which triggered the analyzer.
```go
for _, policy := range policies.Items {
oc.AddNetworkPolicy(&policy)
}
```
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 {
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(newWatchBroadcasts, 1)" -> {}
"(Do, 3)" -> {}
"(Add, 1)" -> {"(Do, 3)";"(New, 1)";"(add, 1)";"(Add, 2)";}
"(New, 1)" -> {"(newClient, 1)";"(Run, 1)";"(SetTransportDefaults, 1)";"(Start, 1)";}
"(Set, 2)" -> {"(Do, 3)";}
"(AddFilteredPodHandler, 4)" -> {"(addHandler, 5)";}
"(post, 1)" -> {"(RoundTrip, 1)";"(GracefulClose, 1)";}
"(NewLease, 1)" -> {}
"(Write, 3)" -> {"(Write, 1)";}
"(AddNetworkPolicy, 1)" -> {"(addNetworkPolicyOld, 1)";"(addNetworkPolicyPortGroup, 1)";}
"(Start, 1)" -> {"(Run, 1)";}
"(NewServer, 1)" -> {"(startNode, 3)";"(restartNode, 2)";"(restartAsStandaloneNode, 2)";}
"(dial, 2)" -> {"(Write, 1)";"(DialURL, 2)";}
"(RoundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";}
"(GracefulClose, 1)" -> {"(Copy, 2)";}
"(newClientTransport, 6)" -> {}
"(newClient, 1)" -> {"(dial, 2)";"(NewLease, 1)";}
"(handleLocalPodSelector, 2)" -> {"(AddFilteredPodHandler, 4)";}
"(add, 1)" -> {"(post, 1)";"(newWatchBroadcast, 3)";"(newWatchBroadcasts, 1)";}
"(addConnIfNeeded, 3)" -> {}
"(tryUpgrade, 2)" -> {}
"(Set, 1)" -> {"(New, 1)";"(Set, 2)";}
"(LabelSelectorAsSelector, 1)" -> {"(Add, 1)";}
"(ServeHTTP, 2)" -> {"(handleHttps, 2)";"(tryUpgrade, 2)";"(serveHTTP, 4)";}
"(DialURL, 2)" -> {"(Dial, 3)";}
"(restartNode, 2)" -> {"(RestartNode, 1)";}
"(handlePeerNamespaceAndPodSelector, 7)" -> {"(AddFilteredNamespaceHandler, 4)";"(AddFilteredPodHandler, 4)";}
"(newWatchBroadcast, 3)" -> {}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(handlePeerNamespaceSelector, 4)" -> {"(AddFilteredNamespaceHandler, 4)";}
"(startNode, 3)" -> {"(StartNode, 2)";}
"(handlePeerPodSelectorOld, 5)" -> {"(AddFilteredPodHandler, 4)";}
"(serveHTTP, 4)" -> {"(tryUpgrade, 7)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(monitorLeader, 1)" -> {}
"(Copy, 2)" -> {"(ServeHTTP, 2)";}
"(handlePeerNamespaceSelectorOld, 4)" -> {"(AddFilteredNamespaceHandler, 4)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(addNetworkPolicyPortGroup, 1)" -> {"(handlePeerNamespaceAndPodSelector, 7)";"(handlePeerNamespaceSelector, 4)";"(handlePeerPodSelector, 5)";"(handleLocalPodSelector, 2)";}
"(newStreamInterceptor, 1)" -> {"(monitorLeader, 1)";}
"(tryUpgrade, 7)" -> {}
"(Write, 1)" -> {"(Copy, 2)";}
"(handleHttps, 2)" -> {"(Server, 2)";}
"(AddFilteredNamespaceHandler, 4)" -> {"(addHandler, 5)";}
"(handleLocalPodSelectorOld, 2)" -> {"(AddFilteredPodHandler, 4)";}
"(awaitOpenSlotForRequest, 1)" -> {}
"(addHandler, 5)" -> {"(LabelSelectorAsSelector, 1)";"(Set, 1)";}
"(handlePeerNamespaceAndPodSelectorOld, 7)" -> {"(AddFilteredNamespaceHandler, 4)";"(AddFilteredPodHandler, 4)";}
"(Add, 2)" -> {"(Write, 3)";}
"(Encode, 2)" -> {"(Write, 1)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(Server, 2)" -> {"(NewServer, 1)";"(newStreamInterceptor, 1)";}
"(restartAsStandaloneNode, 2)" -> {"(RestartNode, 1)";}
"(handlePeerPodSelector, 5)" -> {"(AddFilteredPodHandler, 4)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(StartNode, 2)" -> {}
"(RestartNode, 1)" -> {}
"(addNetworkPolicyOld, 1)" -> {"(handlePeerNamespaceSelectorOld, 4)";"(handlePeerPodSelectorOld, 5)";"(handleLocalPodSelectorOld, 2)";"(handlePeerNamespaceAndPodSelectorOld, 7)";}
"(Run, 1)" -> {"(Write, 1)";"(Encode, 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: fd18dd0bebcddcead0778dcfa1c25704708d04bb
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in go-controller/pkg/cluster/master.go at lines 153-155 and inspect the range over policies.Items together with AddNetworkPolicy. Trace the reported pointer and goroutine paths in the analyzer output, then determine whether the finding is a Bug, Mitigated, or Desirable Behavior and leave the corresponding reaction on the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100