github-vet / github-vet/rangeloop-pointer-findings
CooperAever/Distributed-Systems-KV: src/shardkv/server.go; 22 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [CooperAever/Distributed-Systems-KV](https://www.github.com/CooperAever/Distributed-Systems-KV) at [src/shardkv/server.go](https://github.com/CooperAever/Distributed-Systems-KV/blob/fc64925575bcad626faa4720879d48b530882fdb/src/shardkv/server.go#L208-L229)
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 cfgNum used in defer or goroutine at line 221
[Click here to see the code in its original context.](https://github.com/CooperAever/Distributed-Systems-KV/blob/fc64925575bcad626faa4720879d48b530882fdb/src/shardkv/server.go#L208-L229)
Click here to show the 22 line(s) of Go which triggered the analyzer.
```go
for cfgNum, shards := range kv.garbages {
for shard := range shards {
wait.Add(1)
go func(shard int, cfg shardmaster.Config) {
defer wait.Done()
args := MigrateArgs{shard, cfg.Num}
gid := cfg.Shards[shard]
for _, server := range cfg.Groups[gid] {
srv := kv.make_end(server)
reply := MigrateReply{}
if ok := srv.Call("ShardKV.GarbageCollection", &args, &reply); ok && reply.Err == OK {
kv.mu.Lock()
defer kv.mu.Unlock()
delete(kv.garbages[cfgNum], shard)
if len(kv.garbages[cfgNum]) == 0 {
delete(kv.garbages, cfgNum)
}
}
}
}(shard, kv.mck.Query(cfgNum))
}
}
```
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: fc64925575bcad626faa4720879d48b530882fdb
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.