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

futurewei-cloud/global-scheduler: test/e2e/scheduling/priorities.go; 11 LoC

Open
#12,543 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 [futurewei-cloud/global-scheduler](https://www.github.com/futurewei-cloud/global-scheduler) at [test/e2e/scheduling/priorities.go](https://github.com/futurewei-cloud/global-scheduler/blob/b9329a9fbcd5ca571c8acc498b9d42f5e8b9c19e/test/e2e/scheduling/priorities.go#L333-L343)

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 pod at line 337 may start a goroutine

[Click here to see the code in its original context.](https://github.com/futurewei-cloud/global-scheduler/blob/b9329a9fbcd5ca571c8acc498b9d42f5e8b9c19e/test/e2e/scheduling/priorities.go#L333-L343)

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

```go
for _, pod := range allpods.Items {
if pod.Spec.NodeName == node.Name {
e2elog.Logf("Pod for on the node: %v, Cpu: %v, Mem: %v", pod.Name, getNonZeroRequests(&pod).MilliCPU, getNonZeroRequests(&pod).Memory)
// Ignore best effort pods while computing fractions as they won't be taken in account by scheduler.
if v1qos.GetPodQOS(&pod) == v1.PodQOSBestEffort {
continue
}
totalRequestedCPUResource += getNonZeroRequests(&pod).MilliCPU
totalRequestedMemResource += getNonZeroRequests(&pod).Memory
}
}

```

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 {
"(Delete, 1)" -> {"(Get, 2)";"(drainRespBody, 1)";"(New, 1)";}
"(updateTransport, 5)" -> {"(addCertRotation, 6)";}
"(run, 6)" -> {}
"(writeJSON, 4)" -> {"(Write, 1)";}
"(tryUpgrade, 2)" -> {}
"(handleHttps, 2)" -> {}
"(dial, 1)" -> {"(dialWithoutProxy, 2)";}
"(newWatchBroadcast, 3)" -> {}
"(NewSSHTunnelList, 4)" -> {}
"(v2auth, 4)" -> {"(Create, 2)";}
"(Start, 1)" -> {"(CreateListener, 1)";"(Run, 1)";"(Create, 1)";"(start, 1)";}
"(dial, 2)" -> {"(DialURL, 3)";}
"(Create, 2)" -> {"(run, 6)";}
"(writeXML, 4)" -> {"(Write, 1)";}
"(Authenticate, 2)" -> {"(v2auth, 4)";"(v3auth, 4)";}
"(RoundTripOpt, 2)" -> {"(roundTrip, 1)";}
"(GetPodQOS, 1)" -> {"(Add, 1)";}
"(RunKubelet, 3)" -> {"(createAndInitKubelet, 31)";"(startKubelet, 6)";}
"(DeleteCollection, 4)" -> {}
"(Open, 3)" -> {"(openAtIndex, 4)";}
"(Authenticate, 1)" -> {"(Authenticate, 3)";}
"(apply, 2)" -> {"(applyEntryNormal, 1)";}
"(Authenticate, 3)" -> {"(Authenticate, 2)";}
"(post, 1)" -> {"(RoundTrip, 1)";}
"(add, 2)" -> {"(New, 1)";"(add, 1)";}
"(List, 1)" -> {"(List, 2)";}
"(delete, 1)" -> {"(Delete, 1)";}
"(ListenPipe, 2)" -> {}
"(simulate, 3)" -> {"(AddPod, 1)";}
"(Verifier, 1)" -> {"(newAsyncIDTokenVerifier, 3)";}
"(Insert, 2)" -> {"(drainRespBody, 1)";}
"(Put, 1)" -> {"(drainRespBody, 1)";"(Update, 3)";}
"(drainRespBody, 1)" -> {"(Copy, 2)";}
"(newAsyncIDTokenVerifier, 3)" -> {}
"(startKubelet, 6)" -> {}
"(DialURL, 3)" -> {"(Dial, 3)";}
"(Run, 1)" -> {"(start, 1)";"(Run, 2)";"(Write, 1)";"(Register, 2)";"(copyToPod, 3)";"(NewSSHTunnelList, 4)";"(run, 1)";}
"(NewMainKubelet, 31)" -> {}
"(List, 2)" -> {}
"(Has, 1)" -> {"(Get, 1)";}
"(nodeShouldRunDaemonPod, 2)" -> {"(simulate, 3)";}
"(includeExecFifo, 1)" -> {"(Open, 3)";}
"(openAtIndex, 4)" -> {"(newFilePipeline, 3)";}
"(addEndpoint, 1)" -> {}
"(newFilePipeline, 3)" -> {}
"(Push, 2)" -> {"(New, 1)";"(Get, 0)";"(Put, 1)";}
"(Search, 2)" -> {"(List, 1)";}
"(RoundTrip, 1)" -> {"(roundTrip, 1)";"(RoundTripOpt, 2)";"(Dial, 1)";"(ConnectWithRedirects, 6)";}
"(awaitOpenSlotForRequest, 1)" -> {}
"(Dial, 1)" -> {"(dial, 1)";"(dial, 2)";}
"(v3auth, 4)" -> {"(Create, 2)";}
"(Run, 3)" -> {"(run, 3)";}
"(append, 1)" -> {}
"(startZfsWatcher, 1)" -> {}
"(newClient, 1)" -> {"(NewMaintenance, 1)";}
"(Copy, 2)" -> {"(AddNode, 1)";"(ServeHTTP, 2)";}
"(Write, 1)" -> {"(append, 1)";"(Copy, 2)";}
"(serveResource, 6)" -> {"(DeleteCollection, 4)";}
"(Create, 1)" -> {"(Apply, 1)";}
"(NewMaintenance, 1)" -> {"(Dial, 1)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(run, 1)" -> {}
"(addConnIfNeeded, 3)" -> {}
"(roundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";}
"(newParentProcess, 1)" -> {"(includeExecFifo, 1)";}
"(startThinPoolWatcher, 1)" -> {}
"(createAndInitKubelet, 31)" -> {"(NewMainKubelet, 31)";}
"(New, 2)" -> {"(Start, 1)";}
"(Register, 2)" -> {"(addEndpoint, 1)";}
"(Read, 1)" -> {"(Copy, 2)";}
"(CreateListener, 1)" -> {"(ListenPipe, 2)";}
"(Register, 3)" -> {"(startThinPoolWatcher, 1)";"(startZfsWatcher, 1)";}
"(Get, 1)" -> {"(Read, 1)";}
"(Update, 3)" -> {"(Accept, 2)";}
"(newClientTransport, 6)" -> {}
"(applyEntryNormal, 1)" -> {"(Apply, 1)";}
"(ConnectWithRedirects, 6)" -> {"(Dial, 1)";}
"(Add, 1)" -> {"(Delete, 1)";"(add, 2)";"(Search, 2)";"(Has, 1)";"(insert, 1)";"(add, 1)";"(New, 1)";"(Add, 2)";"(Push, 2)";"(get, 1)";"(delete, 1)";}
"(Add, 2)" -> {"(Write, 3)";"(Search, 2)";"(Insert, 2)";"(New, 1)";}
"(Get, 2)" -> {"(Accept, 2)";}
"(Run, 2)" -> {"(run, 1)";"(CreateControllerContext, 4)";"(Register, 2)";"(Register, 3)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(ServeHTTP, 2)" -> {"(tryUpgrade, 2)";"(handleHttps, 2)";"(proxy, 2)";"(serveResource, 6)";}
"(proxy, 2)" -> {}
"(start, 1)" -> {"(newParentProcess, 1)";}
"(run, 3)" -> {"(RunKubelet, 3)";"(buildKubeletClientConfig, 2)";}
"(Get, 0)" -> {"(Get, 2)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(add, 1)" -> {"(newWatchBroadcast, 3)";"(newWatchBroadcasts, 1)";"(New, 1)";"(post, 1)";}
"(get, 1)" -> {"(Get, 1)";"(SetTransportDefaults, 1)";}
"(buildKubeletClientConfig, 2)" -> {"(UpdateTransport, 4)";}
"(CreateControllerContext, 4)" -> {}
"(insert, 1)" -> {"(Search, 2)";}
"(AddPod, 1)" -> {"(UpdatePod, 1)";}
"(UpdatePod, 1)" -> {}
"(New, 1)" -> {"(Run, 2)";"(Verifier, 1)";"(apply, 2)";"(New, 2)";"(Start, 1)";"(Run, 3)";"(newClient, 1)";"(Run, 1)";}
"(copyToPod, 3)" -> {}
"(UpdateTransport, 4)" -> {"(updateTransport, 5)";}
"(Accept, 2)" -> {}
"(Write, 3)" -> {"(Write, 1)";"(writeXML, 4)";"(writeJSON, 4)";}
"(Apply, 1)" -> {"(Authenticate, 1)";}
"(newWatchBroadcasts, 1)" -> {}
"(addCertRotation, 6)" -> {}
"(AddNode, 1)" -> {"(addNode, 1)";}
"(addNode, 1)" -> {"(nodeShouldRunDaemonPod, 2)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
}

```

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: b9329a9fbcd5ca571c8acc498b9d42f5e8b9c19e

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with test/e2e/scheduling/priorities.go at lines 333-343 and inspect the calls receiving &pod, especially getNonZeroRequests and v1qos.GetPodQOS. Check whether any referenced value can outlive the loop iteration or start a goroutine, then compare that evidence with the analyzer report. Done means leaving the issue’s requested Bug, Mitigated, or Desirable Behavior reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.