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

yunionio/onecloud: pkg/apigateway/handler/misc.go; 3 LoC

Open
#11,823 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 [yunionio/onecloud](https://www.github.com/yunionio/onecloud) at [pkg/apigateway/handler/misc.go](https:%2F%2Fgithub.com%2Fyunionio%2Fonecloud%2Fblob%2Fd3ee28b4d096394313de7211542f0847b2220290%2Fpkg%2Fapigateway%2Fhandler%2Fmisc.go%23L593-L595)

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 record at line 594 may start a goroutine

[Click here to see the code in its original context.](https:%2F%2Fgithub.com%2Fyunionio%2Fonecloud%2Fblob%2Fd3ee28b4d096394313de7211542f0847b2220290%2Fpkg%2Fapigateway%2Fhandler%2Fmisc.go%23L593-L595)

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

```go
for i, record := range records {
xlsx.SetSheetRow(sheetName, fmt.Sprintf("A%d", i+1), &record)
}

```

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 {
"(get, 1)" -> {"(Run, 1)";"(SetTransportDefaults, 1)";"(Decode, 2)";"(Open, 1)";"(Do, 1)";}
"(createEncoderOfType, 2)" -> {"(_createEncoderOfType, 2)";}
"(ServeHTTP, 2)" -> {"(doProxy, 2)";"(ServeDNS, 3)";"(newServerConn, 4)";"(NewTTYServer, 1)";}
"(SetSheetRow, 3)" -> {"(Map, 2)";}
"(waitTimeOut, 2)" -> {}
"(Start, 1)" -> {"(start, 1)";"(startWithListenerFds, 3)";}
"(Handler, 1)" -> {"(ServeHTTP, 2)";}
"(NewSession, 2)" -> {}
"(start, 1)" -> {}
"(CloseBody, 1)" -> {"(Read, 1)";}
"(Encode, 2)" -> {"(encoderOfMapKey, 2)";}
"(Set, 1)" -> {"(New, 1)";}
"(Write, 1)" -> {"(Do, 1)";"(Decode, 1)";"(Encode, 2)";"(Encode, 1)";}
"(init, 1)" -> {"(waitTimeOut, 2)";}
"(do, 1)" -> {"(NewSession, 2)";}
"(createEncoderOfNative, 2)" -> {"(decoderOfSlice, 2)";}
"(encoderOfStruct, 2)" -> {"(describeStruct, 2)";}
"(describeStruct, 2)" -> {"(append, 1)";}
"(setup, 1)" -> {"(Handler, 1)";"(MustRegister, 2)";}
"(callBack, 1)" -> {}
"(encoderOfType, 2)" -> {"(createEncoderOfType, 2)";}
"(New, 1)" -> {"(newClient, 1)";"(get, 1)";"(Log, 1)";}
"(newClient, 1)" -> {}
"(Do, 1)" -> {"(Upload, 1)";"(init, 1)";"(do, 1)";"(CloseBody, 1)";}
"(startServers, 3)" -> {}
"(addConnIfNeeded, 3)" -> {}
"(decoderOfSlice, 2)" -> {"(append, 1)";}
"(Map, 2)" -> {"(Set, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(Decode, 2)" -> {"(Read, 1)";}
"(read, 1)" -> {"(callBack, 1)";"(watchEvent, 1)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(watchEvent, 1)" -> {}
"(append, 1)" -> {}
"(ServeDNS, 3)" -> {}
"(processPkg, 2)" -> {}
"(Log, 1)" -> {"(Write, 1)";}
"(Read, 1)" -> {"(read, 1)";}
"(encoderOfArray, 2)" -> {"(append, 1)";}
"(startWithListenerFds, 3)" -> {"(startServers, 3)";"(ValidateAndExecuteDirectives, 3)";}
"(NewTTYServer, 1)" -> {"(NewServer, 1)";"(initEventHandler, 1)";}
"(Run, 1)" -> {"(Start, 1)";"(processPkg, 2)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(encoderOfMapKey, 2)" -> {"(encoderOfType, 2)";}
"(encoderOfSlice, 2)" -> {"(append, 1)";}
"(initEventHandler, 1)" -> {"(initSocketHandler, 2)";}
"(Upload, 1)" -> {"(GetDataWithRanges, 2)";}
"(GetDataWithRanges, 2)" -> {}
"(_createEncoderOfType, 2)" -> {"(encoderOfArray, 2)";"(encoderOfSlice, 2)";"(encoderOfMap, 2)";"(createEncoderOfNative, 2)";"(encoderOfStruct, 2)";}
"(Encode, 1)" -> {"(Encode, 2)";}
"(newServerConn, 4)" -> {}
"(Open, 1)" -> {}
"(ValidateAndExecuteDirectives, 3)" -> {"(executeDirectives, 5)";}
"(executeDirectives, 5)" -> {"(setup, 1)";}
"(MustRegister, 2)" -> {"(Handler, 1)";}
"(initSocketHandler, 2)" -> {}
"(Decode, 1)" -> {"(Read, 1)";}
"(encoderOfMap, 2)" -> {"(append, 1)";}
"(doProxy, 2)" -> {}
"(NewServer, 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: d3ee28b4d096394313de7211542f0847b2220290

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in pkg/apigateway/handler/misc.go at lines 593-595 and inspect the call to xlsx.SetSheetRow with the range variable reference. Trace whether the referenced record can escape into a goroutine, using the analyzer's call graph as context. Done means classifying the finding as Bug, Mitigated, or Desirable Behavior based on the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
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.