github-vet / github-vet/rangeloop-pointer-findings
decred/dcrdex: client/asset/btc/livetest/livetest.go; 12 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [decred/dcrdex](https://www.github.com/decred/dcrdex) at [client/asset/btc/livetest/livetest.go](https://github.com/decred/dcrdex/blob/3f6e4299c81751558891bcc209cd50825e10183c/client/asset/btc/livetest/livetest.go#L97-L108)
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 cm used in defer or goroutine at line 100
[Click here to see the code in its original context.](https://github.com/decred/dcrdex/blob/3f6e4299c81751558891bcc209cd50825e10183c/client/asset/btc/livetest/livetest.go#L97-L108)
Click here to show the 12 line(s) of Go which triggered the analyzer.
```go
for name, cm := range rig.connectionMasters {
closed := make(chan struct{})
go func() {
cm.Disconnect()
close(closed)
}()
select {
case <-closed:
case <-time.NewTimer(time.Second).C:
rig.t.Fatalf("failed to disconnect from %s", name)
}
}
```
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: 3f6e4299c81751558891bcc209cd50825e10183c
Contributor guide
No contributing guide indexed for this repository
Research direction
Read client/asset/btc/livetest/livetest.go at lines 97-108 and review how the goroutine uses the range-loop variable cm. Check whether the reported capture can affect which connection master is disconnected, then classify the finding with a reaction as Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100