github-vet / github-vet/rangeloop-pointer-findings
cortexproject/cortex: tools/blocksconvert/scheduler/scheduler.go; 31 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cortexproject/cortex](https://www.github.com/cortexproject/cortex) at [tools/blocksconvert/scheduler/scheduler.go](https://github.com/cortexproject/cortex/blob/235bc4ee0984a37cad74538a71bbad6fa18dfe8c/tools/blocksconvert/scheduler/scheduler.go#L183-L213)
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 plan at line 186 may start a goroutine
[Click here to see the code in its original context.](https://github.com/cortexproject/cortex/blob/235bc4ee0984a37cad74538a71bbad6fa18dfe8c/tools/blocksconvert/scheduler/scheduler.go#L183-L213)
Click here to show the 31 line(s) of Go which triggered the analyzer.
```go
for base, plan := range userPlans {
st := plan.Status()
if st == InProgress {
s.deleteObsoleteProgressFiles(ctx, &plan, path.Join(userPrefix, base))
// After deleting old progress files, status might have changed from InProgress to Error.
st = plan.Status()
}
mu.Lock()
allPlans[user][base] = plan
stats[st]++
mu.Unlock()
if st != New {
continue
}
dayIndex, err := strconv.ParseInt(base, 10, 32)
if err != nil {
level.Warn(s.log).Log("msg", "unable to parse day-index", "planFile", plan.PlanFiles[0])
continue
}
mu.Lock()
queue = append(queue, queuedPlan{
DayIndex: int(dayIndex),
PlanFile: plan.PlanFiles[0],
})
mu.Unlock()
}
```
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 {
"(Handle, 2)" -> {"(ServeHTTP, 2)";}
"(newFile, 4)" -> {"(Get, 1)";}
"(NewUniversalClient, 1)" -> {"(NewClusterClient, 1)";"(NewFailoverClient, 1)";"(NewClient, 1)";}
"(NewNetTransport, 1)" -> {"(tcpListen, 1)";}
"(Register, 1)" -> {"(Get, 2)";}
"(Delete, 2)" -> {"(Delete, 1)";"(doRequest, 1)";"(processRaftRequest, 2)";"(New, 1)";"(Delete, 3)";"(Delete, 6)";"(Request, 3)";}
"(Do, 3)" -> {"(Do, 2)";}
"(Format, 1)" -> {"(shouldLog, 1)";}
"(NewFailoverClient, 1)" -> {"(newConnPool, 1)";}
"(populateSeries, 3)" -> {"(Select, 3)";}
"(send, 1)" -> {"(post, 1)";}
"(processRaftRequest, 2)" -> {"(Register, 1)";}
"(Open, 4)" -> {"(open, 5)";}
"(RestartNode, 1)" -> {}
"(awaitOpenSlotForRequest, 1)" -> {}
"(NewV2, 4)" -> {"(NewClient, 5)";}
"(newLessor, 3)" -> {}
"(Remove, 1)" -> {"(Get, 1)";}
"(post, 1)" -> {}
"(startStreamSeriesSet, 10)" -> {}
"(readWAL, 3)" -> {"(Open, 3)";}
"(Delete, 6)" -> {"(Do, 3)";"(deletePreparer, 5)";}
"(executeBackendRequests, 2)" -> {}
"(initExtensionDeclarations, 3)" -> {"(Init, 1)";}
"(initMessagesDeclarations, 3)" -> {"(initFieldsFromDescriptorProto, 3)";"(initExtensionDeclarations, 3)";}
"(parse, 1)" -> {"(append, 1)";"(Get, 1)";}
"(newWatchableStore, 6)" -> {}
"(add, 1)" -> {"(Init, 0)";}
"(RegisterInstrumentation, 1)" -> {"(Handle, 2)";"(Handler, 1)";}
"(proxy, 2)" -> {}
"(Init, 1)" -> {"(loadWAL, 3)";}
"(New, 1)" -> {"(newClient, 1)";"(Open, 4)";"(RegisterInstrumentation, 1)";"(New, 3)";"(New, 2)";"(parse, 1)";"(New, 6)";"(Log, 1)";"(NewServer, 1)";"(newFile, 4)";"(Register, 1)";}
"(Log, 4)" -> {"(Add, 1)";"(merge, 2)";}
"(Add, 1)" -> {"(New, 1)";}
"(Get, 2)" -> {"(query, 3)";}
"(New, 5)" -> {"(NewV2, 4)";}
"(New, 6)" -> {"(newWatchableStore, 6)";}
"(Register, 3)" -> {"(ServeHTTP, 2)";}
"(RoundTripOpt, 2)" -> {"(roundTrip, 1)";}
"(merge, 2)" -> {"(Revoke, 2)";}
"(NewCluster, 1)" -> {"(RetryClusterClient, 1)";}
"(newClient, 1)" -> {"(NewCluster, 1)";}
"(ServeHTTP, 2)" -> {"(executeBackendRequests, 2)";"(proxy, 2)";}
"(restartAsStandaloneNode, 2)" -> {"(RestartNode, 1)";"(readWAL, 3)";}
"(NewClusterClient, 1)" -> {}
"(Series, 2)" -> {"(startStreamSeriesSet, 10)";"(Select, 3)";"(send, 1)";}
"(NewConnPool, 1)" -> {}
"(openAtIndex, 4)" -> {"(newFilePipeline, 3)";}
"(newFilePipeline, 3)" -> {}
"(StartNode, 2)" -> {}
"(writeMetaFile, 3)" -> {"(Create, 1)";}
"(loadWAL, 3)" -> {"(Series, 2)";}
"(execEvalStmt, 3)" -> {"(populateSeries, 3)";"(populateSeries, 2)";}
"(populateSeries, 2)" -> {"(Select, 3)";}
"(initFieldsFromDescriptorProto, 3)" -> {"(Init, 1)";}
"(newClusterNode, 2)" -> {"(NewClient, 1)";}
"(Log, 1)" -> {"(Format, 1)";}
"(RetryClusterClient, 1)" -> {"(NewClusterClient, 1)";}
"(Query, 2)" -> {"(v2Query, 2)";}
"(NewClient, 1)" -> {"(newConnPool, 1)";}
"(Open, 3)" -> {"(openAtIndex, 4)";}
"(NewServer, 1)" -> {"(startNode, 3)";"(restartNode, 2)";"(restartAsStandaloneNode, 2)";"(NewLessor, 3)";}
"(start, 1)" -> {"(Send, 1)";}
"(tcpListen, 1)" -> {}
"(NewLessor, 3)" -> {"(newLessor, 3)";}
"(doRequest, 4)" -> {"(Get, 1)";}
"(NewRedisClient, 1)" -> {"(NewUniversalClient, 1)";}
"(v2Query, 2)" -> {"(Select, 3)";}
"(exec, 2)" -> {"(execEvalStmt, 3)";}
"(deleteObsoleteProgressFiles, 3)" -> {"(Delete, 2)";"(Log, 4)";}
"(append, 1)" -> {}
"(Request, 3)" -> {"(doRequest, 4)";"(Get, 3)";}
"(New, 3)" -> {"(NewRedisClient, 1)";}
"(NewClient, 5)" -> {"(NewClient, 1)";}
"(startNode, 3)" -> {"(RestartNode, 1)";"(StartNode, 2)";}
"(doRequest, 1)" -> {"(Do, 1)";}
"(Revoke, 2)" -> {"(Remove, 1)";"(Info, 2)";}
"(Get, 3)" -> {"(Do, 2)";}
"(Delete, 1)" -> {"(Delete, 3)";}
"(shouldLog, 1)" -> {}
"(deletePreparer, 5)" -> {"(Format, 1)";}
"(Create, 1)" -> {"(newMemberlist, 1)";}
"(New, 2)" -> {"(New, 5)";"(Do, 2)";"(Register, 3)";"(initExtensionDeclarations, 3)";"(New, 3)";"(initMessagesDeclarations, 3)";"(Get, 1)";"(Format, 1)";"(add, 1)";}
"(Delete, 3)" -> {"(Do, 2)";"(writeMetaFile, 3)";"(Log, 1)";}
"(open, 5)" -> {"(Init, 1)";}
"(Select, 3)" -> {}
"(roundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";}
"(Init, 0)" -> {"(Init, 1)";}
"(query, 3)" -> {"(Query, 2)";}
"(Exec, 1)" -> {"(exec, 2)";}
"(Do, 2)" -> {"(Get, 1)";"(RoundTrip, 1)";"(Handle, 2)";"(Exec, 1)";}
"(Info, 2)" -> {"(query, 3)";}
"(newConnPool, 1)" -> {"(NewConnPool, 1)";}
"(Do, 1)" -> {"(Get, 1)";}
"(newMemberlist, 1)" -> {"(NewNetTransport, 1)";}
"(RoundTrip, 1)" -> {"(ServeHTTP, 2)";"(start, 1)";"(roundTrip, 1)";"(RoundTripOpt, 2)";}
"(Send, 1)" -> {"(send, 1)";}
"(Get, 1)" -> {"(newClusterNode, 2)";}
"(restartNode, 2)" -> {"(RestartNode, 1)";"(readWAL, 3)";}
"(Handler, 1)" -> {"(ServeHTTP, 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: 235bc4ee0984a37cad74538a71bbad6fa18dfe8c
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.