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

mzzgaopeng/kubernetes: pkg/controller/endpointslice/reconciler.go; 15 LoC

Open
#11,654 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [mzzgaopeng/kubernetes](https://www.github.com/mzzgaopeng/kubernetes) at [pkg/controller/endpointslice/reconciler.go](https://github.com/mzzgaopeng/kubernetes/blob/ded624b8c7918766a08023e72fa7af79e16be080/pkg/controller/endpointslice/reconciler.go#L272-L286)

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 endpoint at line 284 may start a goroutine

[Click here to see the code in its original context.](https://github.com/mzzgaopeng/kubernetes/blob/ded624b8c7918766a08023e72fa7af79e16be080/pkg/controller/endpointslice/reconciler.go#L272-L286)

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

```go
for _, endpoint := range existingSlice.Endpoints {
got := desiredSet.Get(&endpoint)
// If endpoint is desired add it to list of endpoints to keep.
if got != nil {
newEndpoints = append(newEndpoints, *got)
// If existing version of endpoint doesn't match desired version
// set endpointUpdated to ensure endpoint changes are persisted.
if !endpointsEqualBeyondHash(got, &endpoint) {
endpointUpdated = true
}
// once an endpoint has been placed/found in a slice, it no
// longer needs to be handled
desiredSet.Delete(&endpoint)
}
}

```

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, 5)" -> {"(newWatchableStore, 5)";}
"(post, 1)" -> {"(RoundTrip, 1)";}
"(Register, 3)" -> {"(startThinPoolWatcher, 1)";"(startZfsWatcher, 1)";}
"(ListenPipe, 2)" -> {}
"(addPod, 1)" -> {"(AddPod, 1)";}
"(append, 1)" -> {}
"(newWatchBroadcasts, 1)" -> {}
"(List, 1)" -> {"(List, 2)";"(List, 5)";}
"(Get, 0)" -> {"(get, 1)";}
"(Start, 1)" -> {"(SendRequest, 3)";"(Run, 1)";"(start, 1)";"(CreateListener, 1)";}
"(Run, 3)" -> {"(Run, 1)";"(List, 1)";}
"(NewSSHTunnelList, 4)" -> {}
"(Verifier, 1)" -> {"(newAsyncIDTokenVerifier, 3)";}
"(CreateListener, 1)" -> {"(ListenPipe, 2)";}
"(Search, 2)" -> {"(List, 1)";}
"(UpdatePod, 1)" -> {}
"(roundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";}
"(New, 2)" -> {"(Start, 1)";"(add, 1)";}
"(deleteAllContent, 1)" -> {"(Update, 1)";}
"(handleHttps, 2)" -> {"(RoundTrip, 1)";}
"(newWatchBroadcast, 3)" -> {}
"(awaitOpenSlotForRequest, 1)" -> {}
"(dial, 2)" -> {"(DialURL, 3)";}
"(addConnIfNeeded, 3)" -> {}
"(newFilePipeline, 3)" -> {}
"(DialForUpgrade, 1)" -> {"(dial, 2)";}
"(Copy, 2)" -> {"(ServeHTTP, 2)";}
"(Run, 1)" -> {"(Register, 2)";"(copyToPod, 3)";"(NewSSHTunnelList, 4)";"(start, 1)";"(processPkg, 2)";"(Write, 1)";"(Update, 2)";}
"(add, 1)" -> {"(post, 1)";"(newWatchBroadcast, 3)";"(newWatchBroadcasts, 1)";}
"(updatePod, 2)" -> {"(AddPod, 1)";"(addPod, 1)";}
"(newAuthenticator, 2)" -> {"(SetTransportDefaults, 1)";}
"(copyToPod, 3)" -> {}
"(newAsyncIDTokenVerifier, 3)" -> {}
"(Get, 1)" -> {"(Search, 2)";"(get, 1)";"(Add, 1)";"(Read, 1)";}
"(Remove, 1)" -> {"(Search, 2)";}
"(Delete, 3)" -> {"(Encode, 2)";"(Txn, 1)";}
"(get, 1)" -> {"(SetTransportDefaults, 1)";}
"(openAtIndex, 4)" -> {"(newFilePipeline, 3)";}
"(Delete, 1)" -> {"(Get, 2)";"(drainRespBody, 1)";"(New, 1)";"(Hash, 1)";"(deleteAllContent, 1)";"(Delete, 3)";"(Remove, 2)";}
"(send, 3)" -> {}
"(Add, 1)" -> {"(add, 1)";}
"(EndpointURL, 4)" -> {"(List, 2)";}
"(ServeHTTP, 2)" -> {"(tryUpgrade, 2)";"(handleHttps, 2)";"(proxy, 2)";"(serveResource, 6)";"(List, 1)";"(RoundTrip, 1)";}
"(Remove, 2)" -> {"(Remove, 1)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(DialURL, 3)" -> {"(Dial, 3)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(Read, 1)" -> {"(add, 1)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(RoundTripOpt, 2)" -> {"(roundTrip, 1)";}
"(Open, 3)" -> {"(openAtIndex, 4)";}
"(includeExecFifo, 1)" -> {"(Open, 3)";}
"(NewMaintenance, 1)" -> {"(Dial, 1)";}
"(Dial, 1)" -> {"(dial, 2)";"(dial, 1)";}
"(Get, 2)" -> {"(isObjectFresh, 1)";"(Get, 0)";"(Accept, 2)";"(New, 1)";"(Get, 1)";}
"(start, 1)" -> {"(newParentProcess, 1)";}
"(proxy, 2)" -> {}
"(run, 1)" -> {"(start, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(waitUntilFreshAndBlock, 2)" -> {}
"(newWatchableStore, 5)" -> {}
"(newClientTransport, 6)" -> {}
"(Accept, 2)" -> {}
"(New, 1)" -> {"(newAuthenticator, 2)";"(Start, 1)";"(Run, 1)";"(newClient, 1)";"(NewClient, 2)";"(Add, 1)";"(NewWithTLSConfig, 2)";"(get, 1)";"(New, 2)";"(Run, 3)";"(Run, 2)";"(Verifier, 1)";}
"(Hash, 1)" -> {"(Write, 1)";}
"(startThinPoolWatcher, 1)" -> {}
"(newClient, 1)" -> {"(NewMaintenance, 1)";}
"(Encode, 2)" -> {"(Write, 1)";}
"(newParentProcess, 1)" -> {"(includeExecFifo, 1)";}
"(NewClient, 2)" -> {"(EndpointURL, 4)";}
"(RoundTrip, 1)" -> {"(roundTrip, 1)";"(RoundTripOpt, 2)";"(Dial, 1)";}
"(Update, 2)" -> {"(updatePod, 2)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(drainRespBody, 1)" -> {"(Copy, 2)";}
"(processPkg, 2)" -> {}
"(addEndpoint, 1)" -> {}
"(List, 2)" -> {}
"(Write, 1)" -> {"(append, 1)";}
"(serveResource, 6)" -> {"(DeleteCollection, 4)";}
"(List, 5)" -> {"(WaitUntilFreshAndList, 2)";"(New, 5)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(Txn, 1)" -> {"(Write, 1)";}
"(isObjectFresh, 1)" -> {"(Add, 1)";}
"(AddPod, 1)" -> {"(UpdatePod, 1)";}
"(DeleteCollection, 4)" -> {}
"(CreateControllerContext, 4)" -> {}
"(Register, 2)" -> {"(addEndpoint, 1)";}
"(Update, 1)" -> {"(apply, 4)";"(Add, 1)";"(Update, 2)";}
"(SendRequest, 3)" -> {"(send, 3)";}
"(NewWithTLSConfig, 2)" -> {"(SetTransportDefaults, 1)";}
"(WaitUntilFreshAndList, 2)" -> {"(waitUntilFreshAndBlock, 2)";}
"(dial, 1)" -> {"(dialWithoutProxy, 2)";}
"(Run, 2)" -> {"(List, 1)";"(Run, 1)";"(CreateControllerContext, 4)";"(Start, 1)";"(Register, 2)";"(run, 1)";"(Register, 3)";}
"(apply, 4)" -> {"(post, 1)";}
"(tryUpgrade, 2)" -> {"(DialForUpgrade, 1)";}
"(startZfsWatcher, 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: ded624b8c7918766a08023e72fa7af79e16be080

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.