github-vet / github-vet/rangeloop-pointer-findings
Yang6149/distrubute_KV_storage: src/mr/master.go; 28 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Yang6149/distrubute_KV_storage](https://www.github.com/Yang6149/distrubute_KV_storage) at [src/mr/master.go](https://github.com/Yang6149/distrubute_KV_storage/blob/0009dad1db00d213c08291a6d15d70dcac38ccda/src/mr/master.go#L96-L123)
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 i used in defer or goroutine at line 114
[Click here to see the code in its original context.](https://github.com/Yang6149/distrubute_KV_storage/blob/0009dad1db00d213c08291a6d15d70dcac38ccda/src/mr/master.go#L96-L123)
Click here to show the 28 line(s) of Go which triggered the analyzer.
```go
for i :=range m.reduceTable{
if m.reduceTable[i].status==commited||m.reduceTable[i].status==isworking{
continue
}
//当任务还没开始或任务超时时,分配任务
if m.reduceTable[i].status==idle||m.reduceTable[i].status==0{
m.reduceTable[i].status=isworking
reply.Type=2
reply.Id=i
reply.Filename="mr-out-"+strconv.Itoa(i)
//设立超时,当前任务超过十秒没有完成任务
ctx, _ := context.WithTimeout(context.Background(), m.timeout)
go func() {
select {
case <-ctx.Done():
{
m.mu.Lock()
//再次判断如果任务没有完成则状态改为 dile
if m.reduceTable[i].status!=commited{
m.reduceTable[i].status=idle
}
m.mu.Unlock()
}
}
}()
}
return nil
}
```
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: 0009dad1db00d213c08291a6d15d70dcac38ccda
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.