github-vet / github-vet/rangeloop-pointer-findings

gardener/gardener: pkg/controllermanager/controller/shoot/shoot_reference_control.go; 9 LoC

Open
#17,519 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [gardener/gardener](https://www.github.com/gardener/gardener) at [pkg/controllermanager/controller/shoot/shoot_reference_control.go](https://github.com/gardener/gardener/blob/c6b47316f6f3bf588aba636a1f319f4ee6998aaa/pkg/controllermanager/controller/shoot/shoot_reference_control.go#L352-L360)

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 configMap at line 353 may start a goroutine

[Click here to see the code in its original context.](https://github.com/gardener/gardener/blob/c6b47316f6f3bf588aba636a1f319f4ee6998aaa/pkg/controllermanager/controller/shoot/shoot_reference_control.go#L352-L360)

Click here to show the 9 line(s) of Go which triggered the analyzer.

```go
for _, configMap := range configMaps.Items {
if !controllerutils.HasFinalizer(&configMap, FinalizerName) {
continue
}
if referencedConfigMaps.Has(configMap.Name) {
continue
}
configMapsToRelease = append(configMapsToRelease, configMap)
}

```

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 {
"(newBackend, 5)" -> {"(NewBackend, 1)";}
"(decoderOfSlice, 2)" -> {"(append, 1)";}
"(describeStruct, 2)" -> {"(append, 1)";}
"(newClientTransport, 6)" -> {}
"(run, 1)" -> {"(config, 2)";}
"(Remove, 1)" -> {"(New, 1)";"(Delete, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(encoderOfType, 2)" -> {"(createEncoderOfType, 2)";}
"(Add, 1)" -> {"(Encode, 2)";}
"(config, 2)" -> {"(ApplyTo, 1)";}
"(Dial, 1)" -> {"(dial, 1)";}
"(get, 1)" -> {"(Copy, 2)";"(Run, 1)";"(SetTransportDefaults, 1)";}
"(dial, 1)" -> {"(dialWithoutProxy, 2)";}
"(New, 1)" -> {"(newClient, 1)";"(get, 1)";"(Add, 1)";}
"(addConnIfNeeded, 3)" -> {}
"(Encode, 2)" -> {"(encoderOfMapKey, 2)";}
"(ServeHTTP, 2)" -> {"(serveAggregated, 2)";}
"(Add, 2)" -> {"(Add, 1)";}
"(ApplyTo, 5)" -> {"(newBackend, 5)";}
"(NewBackend, 1)" -> {"(updateSink, 2)";"(deleteSink, 1)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(ApplyTo, 1)" -> {"(ApplyTo, 5)";}
"(Walk, 2)" -> {"(Open, 2)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(check, 1)" -> {"(allReferencedPackages, 2)";}
"(encoderOfMapKey, 2)" -> {"(encoderOfType, 2)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(Get, 3)" -> {"(Do, 2)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(encoderOfMap, 2)" -> {"(append, 1)";}
"(EachType, 2)" -> {"(Walk, 2)";}
"(Get, 1)" -> {"(get, 1)";"(New, 1)";"(Get, 3)";"(Write, 1)";"(Remove, 1)";"(Add, 2)";"(After, 1)";}
"(encoderOfArray, 2)" -> {"(append, 1)";}
"(append, 1)" -> {}
"(allReferencedPackages, 2)" -> {"(EachType, 2)";}
"(serveAggregated, 2)" -> {"(check, 1)";}
"(encoderOfStruct, 2)" -> {"(describeStruct, 2)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(createEncoderOfNative, 2)" -> {"(decoderOfSlice, 2)";}
"(Copy, 2)" -> {"(ServeHTTP, 2)";}
"(Do, 2)" -> {}
"(Write, 1)" -> {"(Copy, 2)";"(Encode, 2)";"(WriteTo, 1)";}
"(updateSink, 2)" -> {}
"(After, 1)" -> {"(Add, 1)";}
"(HasFinalizer, 2)" -> {"(Has, 1)";}
"(NewController, 6)" -> {}
"(Delete, 1)" -> {"(Run, 1)";}
"(encoderOfSlice, 2)" -> {"(append, 1)";}
"(deleteSink, 1)" -> {}
"(Run, 1)" -> {"(NewController, 6)";"(processPkg, 2)";"(run, 1)";}
"(createEncoderOfType, 2)" -> {"(_createEncoderOfType, 2)";}
"(_createEncoderOfType, 2)" -> {"(encoderOfArray, 2)";"(encoderOfSlice, 2)";"(encoderOfMap, 2)";"(createEncoderOfNative, 2)";"(encoderOfStruct, 2)";}
"(WriteTo, 1)" -> {"(run, 1)";}
"(NewMaintenance, 1)" -> {"(Dial, 1)";}
"(Has, 1)" -> {"(Get, 1)";}
"(newClient, 1)" -> {"(NewMaintenance, 1)";}
"(processPkg, 2)" -> {}
"(Open, 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: c6b47316f6f3bf588aba636a1f319f4ee6998aaa

Contributor guide

No contributing guide indexed for this repository

Research direction

Read pkg/controllermanager/controller/shoot/shoot_reference_control.go around lines 352-360, then inspect HasFinalizer and the analyzer context for the reported range-loop reference. 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
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.