github-vet / github-vet/rangeloop-pointer-findings
jkaiser/dedup_simulation: dedupAlgorithms/sparseIndexing/sparseIndexingManager.go; 37 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [jkaiser/dedup_simulation](https://www.github.com/jkaiser/dedup_simulation) at [dedupAlgorithms/sparseIndexing/sparseIndexingManager.go](https://github.com/jkaiser/dedup_simulation/blob/e969e6376f91326eb920d1618ebfa0f7260ac095/dedupAlgorithms/sparseIndexing/sparseIndexingManager.go#L124-L160)
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 fileInfo used in defer or goroutine at line 150
[Click here to see the code in its original context.](https://github.com/jkaiser/dedup_simulation/blob/e969e6376f91326eb920d1618ebfa0f7260ac095/dedupAlgorithms/sparseIndexing/sparseIndexingManager.go#L124-L160)
Click here to show the 37 line(s) of Go which triggered the analyzer.
```go
for _, fileInfo := range fileInfoList {
var hostname string
// start new generation and create data structures if necesary
if strings.Contains(sm.config.DataSet, "multi") { // if parallel run, determine the hostname
var splits []string = strings.Split(fileInfo.Name, "_")
hostname = strings.Split(splits[len(splits)-1], "-")[0]
} else {
hostname = "host0"
}
log.Info("gen ", genNum, ": processing host: ", hostname)
if _, ok := sm.sparseIndexingMap[hostname]; !ok {
sm.sparseIndexingMap[hostname] = sm.CreateSparseIndexing()
}
si := sm.sparseIndexingMap[hostname]
usedSparseIndices[hostname] = si
si.BeginTraceFile(genNum, fileInfo.Name)
// si instance is ready
go func(gen int, siHandler *SparseIndexing, tracePath string) {
defer wg.Done()
fileEntryChan := make(chan *algocommon.FileEntry, algocommon.ConstMaxFileEntries)
log.Info("gen ", gen, ": generate TraceDataReader for path: ", fileInfo.Path)
tReader := algocommon.NewTraceDataReader(tracePath)
go tReader.FeedAlgorithm(fileEntryChan)
sameMomentStartWG.Done() // synchronize the start of every file backup
sameMomentStartWG.Wait()
siHandler.HandleFiles(fileEntryChan, tReader.GetFileEntryReturn())
siHandler.EndTraceFile()
}(genNum, si, fileInfo.Path)
}
```
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: e969e6376f91326eb920d1618ebfa0f7260ac095
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.