github-vet / github-vet/rangeloop-pointer-findings
sipsma/bincastle: buildkit/frontend.go; 43 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [sipsma/bincastle](https://www.github.com/sipsma/bincastle) at [buildkit/frontend.go](https://github.com/sipsma/bincastle/blob/7280f381ce1c6b4afc220759ed2f7a61c7a3bdd5/buildkit/frontend.go#L229-L271)
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 req used in defer or goroutine at line 239
[Click here to see the code in its original context.](https://github.com/sipsma/bincastle/blob/7280f381ce1c6b4afc220759ed2f7a61c7a3bdd5/buildkit/frontend.go#L229-L271)
Click here to show the 43 line(s) of Go which triggered the analyzer.
```go
for req := range f.newSolveCh {
if origCtx == nil {
origCtx = req.ctx
}
solveCtx, solveCancel := context.WithCancel(origCtx)
done := make(chan *solveResult)
started := make(chan struct{})
go func() {
defer close(done)
err := f.exec(solveCtx, llbBridge, req.args, sid, req.layers, req.mounts, started)
done <- &solveResult{Result: &frontend.Result{}, err: err}
}()
select {
case res := <-done:
solveCancel()
req.resultCh <- res
if len(execReqs) > 0 {
lastIndex := len(execReqs) - 1
prevExec := execReqs[lastIndex]
prevExec.resultCh = execReqs[0].resultCh
select {
case f.newSolveCh <- prevExec:
execReqs = execReqs[:lastIndex]
default:
}
}
case newReq := <-f.newSolveCh:
solveCancel()
res := <-done
execReqs = append(execReqs, req)
if len(execReqs) > 1 {
req.resultCh <- res
}
select {
case f.newSolveCh <- newReq:
default:
// another request came along in the meantime; go with that instead
newReq.resultCh <- &solveResult{err: context.Canceled} // TODO use custom error
}
}
}
```
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: 7280f381ce1c6b4afc220759ed2f7a61c7a3bdd5
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.