github-vet / github-vet/rangeloop-pointer-findings
dlespiau/obs: observer.go; 35 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [dlespiau/obs](https://www.github.com/dlespiau/obs) at [observer.go](https://github.com/dlespiau/obs/blob/83e41ec6506193e18dea6a385944fc3f3c126773/observer.go#L54-L88)
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 data used in defer or goroutine at line 80
[Click here to see the code in its original context.](https://github.com/dlespiau/obs/blob/83e41ec6506193e18dea6a385944fc3f3c126773/observer.go#L54-L88)
Click here to show the 35 line(s) of Go which triggered the analyzer.
```go
for _, data := range o.tracepoints {
tp := data.tp
source := data.source
if err = tp.open(); err != nil {
return err
}
o.wg.Add(1)
go func(tp *tracepoint, source EventSource) {
// TODO(damien): should we hide the implementation details into the
// tracepoint object and have it provide a channel?
for {
var nFds int
nFds, err = tp.perf.poll(-1)
if err != nil {
break
}
if nFds == 0 {
break
}
tp.perf.read(func(msg *perfEventSample, cpu int) {
event := &TracepointEvent{
baseEvent: baseEvent{
source: source,
},
tp: tp,
data: msg.DataCopy(),
}
o.events <- event
}, nil)
}
o.wg.Done()
}(tp, source)
}
```
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: 83e41ec6506193e18dea6a385944fc3f3c126773
Contributor guide
No contributing guide indexed for this repository
Research direction
Read observer.go lines 54-88 and compare the analyzer warning with the goroutine's arguments and captured variables. Decide whether the reported range-loop use is a real bug, mitigated, or desirable behavior, then leave the corresponding reaction on the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100