github-vet / github-vet/rangeloop-pointer-findings
openshift/hive: pkg/controller/clustersync/clustersync_controller.go; 6 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [openshift/hive](https://www.github.com/openshift/hive) at [pkg/controller/clustersync/clustersync_controller.go](https://github.com/openshift/hive/blob/93e5a9fee058fd4cd308594be890c05415cb41ed/pkg/controller/clustersync/clustersync_controller.go#L973-L978)
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 sss at line 974 may start a goroutine
[Click here to see the code in its original context.](https://github.com/openshift/hive/blob/93e5a9fee058fd4cd308594be890c05415cb41ed/pkg/controller/clustersync/clustersync_controller.go#L973-L978)
Click here to show the 6 line(s) of Go which triggered the analyzer.
```go
for i, sss := range selectorSyncSetsList.Items {
if !doesSelectorSyncSetApplyToClusterDeployment(&sss, cd, logger) {
continue
}
selectorSyncSets = append(selectorSyncSets, (*SelectorSyncSetAsCommon)(&selectorSyncSetsList.Items[i]))
}
```
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 {
"(New, 2)" -> {"(Run, 1)";}
"(NewClientWithMetricsOrDie, 3)" -> {"(New, 2)";}
"(newClient, 1)" -> {"(NewMaintenance, 1)";}
"(append, 1)" -> {}
"(Get, 3)" -> {"(Do, 3)";"(Request, 3)";"(Get, 4)";}
"(WriteTo, 1)" -> {"(Copy, 2)";"(run, 1)";}
"(Request, 3)" -> {"(doRequest, 4)";}
"(Get, 4)" -> {"(WaitUntilFreshAndGet, 3)";}
"(WaitUntilFreshAndGet, 3)" -> {"(waitUntilFreshAndBlock, 2)";}
"(doesSelectorSyncSetApplyToClusterDeployment, 3)" -> {"(Set, 1)";"(LabelSelectorAsSelector, 1)";}
"(serveAggregated, 2)" -> {"(check, 1)";}
"(Copy, 2)" -> {"(ServeHTTP, 2)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(doRequest, 4)" -> {"(Copy, 2)";}
"(waitUntilFreshAndBlock, 2)" -> {}
"(run, 1)" -> {"(Check, 1)";}
"(Check, 1)" -> {"(check, 1)";}
"(Do, 3)" -> {"(Copy, 2)";}
"(processPkg, 2)" -> {}
"(check, 1)" -> {}
"(runCmdContext, 2)" -> {}
"(Dial, 1)" -> {"(dial, 1)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(computeEditsFromProg, 1)" -> {}
"(Add, 1)" -> {"(createActuator, 5)";"(add, 2)";"(New, 1)";"(NewClientWithMetricsOrDie, 3)";}
"(Parse, 1)" -> {"(handle, 1)";"(parseText, 1)";"(Decode, 1)";"(parse, 1)";}
"(addConnIfNeeded, 3)" -> {"(run, 3)";}
"(New, 1)" -> {"(newClient, 1)";"(get, 1)";"(Parse, 1)";"(parse, 1)";}
"(parseText, 1)" -> {"(append, 1)";}
"(parse, 1)" -> {"(Write, 1)";}
"(Write, 1)" -> {"(append, 1)";"(WriteTo, 1)";}
"(Run, 1)" -> {"(computeEditsFromProg, 1)";"(processPkg, 2)";}
"(add, 2)" -> {"(New, 2)";"(Get, 3)";}
"(Decode, 1)" -> {"(unmarshal, 2)";}
"(Receive, 2)" -> {"(Copy, 2)";}
"(LabelSelectorAsSelector, 1)" -> {"(Add, 1)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(handle, 1)" -> {"(Receive, 2)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(ServeHTTP, 2)" -> {"(serveAggregated, 2)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(newClientTransport, 6)" -> {}
"(get, 1)" -> {"(Run, 1)";"(SetTransportDefaults, 1)";}
"(createActuator, 5)" -> {"(Get, 3)";}
"(unmarshal, 2)" -> {"(Copy, 2)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(run, 3)" -> {"(runCmdContext, 2)";}
"(NewMaintenance, 1)" -> {"(Dial, 1)";}
"(dial, 1)" -> {"(dialWithoutProxy, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(Set, 1)" -> {"(New, 1)";}
}
```
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: 93e5a9fee058fd4cd308594be890c05415cb41ed
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading pkg/controller/clustersync/clustersync_controller.go around lines 973-978, then trace doesSelectorSyncSetApplyToClusterDeployment and the use of selectorSyncSets. Determine whether the referenced range variable can escape into a goroutine; done means confirming the analyzer finding and leaving the requested Bug, Mitigated, or Desirable Behavior reaction.
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
- 25/100