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

coreos/coreos-assembler: tools/vendor/github.com/minio/minio/cmd/global-heal.go; 46 LoC

Open
#16,560 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 [coreos/coreos-assembler](https://www.github.com/coreos/coreos-assembler) at [tools/vendor/github.com/minio/minio/cmd/global-heal.go](https://github.com/coreos/coreos-assembler/blob/60e6c83a6ec7e9f67231d3cbbe3987c833eb4758/tools/vendor/github.com/minio/minio/cmd/global-heal.go#L130-L175)

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 bucket used in defer or goroutine at line 144

[Click here to see the code in its original context.](https://github.com/coreos/coreos-assembler/blob/60e6c83a6ec7e9f67231d3cbbe3987c833eb4758/tools/vendor/github.com/minio/minio/cmd/global-heal.go#L130-L175)

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

```go
for _, bucket := range buckets {
// Heal current bucket
bgSeq.sourceCh <- healSource{
bucket: bucket.Name,
}

var entryChs []FileInfoVersionsCh
var mu sync.Mutex
var wg sync.WaitGroup
for _, disk := range disks {
disk := disk
wg.Add(1)
go func() {
defer wg.Done()
entryCh, err := disk.WalkVersions(ctx, bucket.Name, "", "", true, ctx.Done())
if err != nil {
// Disk walk returned error, ignore it.
return
}
mu.Lock()
entryChs = append(entryChs, FileInfoVersionsCh{
Ch: entryCh,
})
mu.Unlock()
}()
}
wg.Wait()

entriesValid := make([]bool, len(entryChs))
entries := make([]FileInfoVersions, len(entryChs))

for {
entry, _, ok := lexicallySortedEntryVersions(entryChs, entries, entriesValid)
if !ok {
break
}

for _, version := range entry.Versions {
bgSeq.sourceCh <- healSource{
bucket: bucket.Name,
object: version.Name,
versionID: version.VersionID,
}
}
}
}

```

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: 60e6c83a6ec7e9f67231d3cbbe3987c833eb4758

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.