github-vet / github-vet/rangeloop-pointer-findings
rai-project/dlframework: framework/cmd/server/predict_urls.go; 49 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [rai-project/dlframework](https://www.github.com/rai-project/dlframework) at [framework/cmd/server/predict_urls.go](https://github.com/rai-project/dlframework/blob/4aaa12cfa5874a785cbe70a2bc8a849472c7bc95/framework/cmd/server/predict_urls.go#L270-L318)
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.
> range-loop variable part used in defer or goroutine at line 274
[Click here to see the code in its original context.](https://github.com/rai-project/dlframework/blob/4aaa12cfa5874a785cbe70a2bc8a849472c7bc95/framework/cmd/server/predict_urls.go#L270-L318)
Click here to show the 49 line(s) of Go which triggered the analyzer.
```go
for _, part := range urlParts[0:numWarmUpUrlParts] {
input := make(chan interface{}, DefaultChannelBuffer)
go func() {
defer close(input)
for _, url := range part {
id := uuid.NewV4()
lbl := steps.NewIDWrapper(id, url)
partlabels[lbl.GetID()] = "" // no label for the input url
input <- lbl
}
}()
opts := []pipeline.Option{pipeline.ChannelBuffer(DefaultChannelBuffer)}
if tracePreprocess == true {
opts = append(opts, pipeline.Context(warmUpSpanCtx))
}
output := pipeline.New(opts...).
Then(steps.NewReadURL()).
Then(steps.NewReadImage(preprocessOptions)).
Then(steps.NewPreprocessImage(preprocessOptions)).
Run(input)
var images []interface{}
for out := range output {
images = append(images, out)
}
imageParts := dl.Partition(images, batchSize)
input = make(chan interface{}, DefaultChannelBuffer)
go func() {
defer close(input)
for _, p := range imageParts {
input <- p
}
}()
output = pipeline.New(pipeline.Context(warmUpSpanCtx), pipeline.ChannelBuffer(DefaultChannelBuffer)).
Then(steps.NewPredict(predictor)).
Run(input)
for o := range output {
if err, ok := o.(error); ok && failOnFirstError {
log.WithError(err).Error("encountered an error while performing warmup inference")
os.Exit(-1)
}
outputs <- o
}
}
```
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: 4aaa12cfa5874a785cbe70a2bc8a849472c7bc95
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.