github-vet / github-vet/rangeloop-pointer-findings
MatrixAINetwork/go-matrix: msgsend/dispatcher.go; 13 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [MatrixAINetwork/go-matrix](https://www.github.com/MatrixAINetwork/go-matrix) at [msgsend/dispatcher.go](https://github.com/MatrixAINetwork/go-matrix/blob/aed2396f13b5801b5f36c892077ee73ab4354e16/msgsend/dispatcher.go#L63-L75)
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 addr used in defer or goroutine at line 70
[Click here to see the code in its original context.](https://github.com/MatrixAINetwork/go-matrix/blob/aed2396f13b5801b5f36c892077ee73ab4354e16/msgsend/dispatcher.go#L63-L75)
Click here to show the 13 line(s) of Go which triggered the analyzer.
```go
for _, addr := range nodes {
if err != nil {
log.Error("SendToSignal", "ConvertAddressToNodeId err", err, "address", addr.Hex())
continue
}
log.Info("SendToSignal", "address", addr.Hex())
go func() {
err := p2p.SendToSingle(addr, common.AlgorithmMsg, sendData)
if err != nil {
log.Error("SendToSignal", "address", addr.Hex(), "err", err)
}
}()
}
```
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: aed2396f13b5801b5f36c892077ee73ab4354e16
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in msgsend/dispatcher.go at lines 63-75 and inspect how the range variable addr is used by the goroutine. Check the surrounding message-sending flow and available Go tests. Done means the asynchronous sends and error logs use the intended address for each node without capturing the loop variable incorrectly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100