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

nbedos/cistern: providers/cache.go; 32 LoC

Open
#17,584 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 [nbedos/cistern](https://www.github.com/nbedos/cistern) at [providers/cache.go](https://github.com/nbedos/cistern/blob/ba29e81999bdc4873696b202c205d62c0309c243/providers/cache.go#L791-L822)

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 commit used in defer or goroutine at line 810

[Click here to see the code in its original context.](https://github.com/nbedos/cistern/blob/ba29e81999bdc4873696b202c205d62c0309c243/providers/cache.go#L791-L822)

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

```go
for commit := range commitc {
c.SaveCommit(ref.Name, commit)
if updates != nil {
wg.Add(1)
go func() {
defer wg.Done()
select {
case updates <- PipelineChanges{}:
// Do nothing
case <-ctx.Done():
// Do nothing
}
}()
}
for _, u := range commit.Statuses {
if _, exists := urls[u]; !exists {
wg.Add(1)
go func(u string) {
defer wg.Done()
err := c.broadcastMonitorPipeline(ctx, commit.Sha, u, updates)
// Ignore ErrUnknownPipelineURL. This error means that we don't integrate
// with the application that created that particular url. No need to report
// this up the chain, though it's nice to know our request couldn't be handled.
if err != ErrUnknownPipelineURL {
errc <- err
return
}
}(u)
urls[u] = struct{}{}
}
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Read providers/cache.go around lines 791-822 and inspect the reported range-loop variable capture in the goroutine and defer usage. Compare the analyzer warning with the surrounding code and determine whether this is a real bug, mitigated behavior, or desirable behavior; record that classification as the issue's reaction.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.