github-vet / github-vet/rangeloop-pointer-findings

z0rr0/luss: core/core.go; 30 LoC

Open
#16,823 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [z0rr0/luss](https://www.github.com/z0rr0/luss) at [core/core.go](https://github.com/z0rr0/luss/blob/b5a4b96ab4efc170332a76953fe541405f18b46d/core/core.go#L67-L96)

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 cui used in defer or goroutine at line 81

[Click here to see the code in its original context.](https://github.com/z0rr0/luss/blob/b5a4b96ab4efc170332a76953fe541405f18b46d/core/core.go#L67-L96)

Click here to show the 30 line(s) of Go which triggered the analyzer.

```go
for cui := range ch {
c, err := conf.FromContext(cui.ctx)
if err != nil {
logger.Printf("tracker wasn't called, error: %v", err)
continue
}
if !c.Settings.TrackOn {
c.L.Debug.Println("request tracking is disabled")
continue
}
wg.Add(2)
// tracker handler
go func() {
defer wg.Done()
if err := stats.Tracker(cui.ctx, cui.cu, cui.addr); err != nil {
c.L.Error.Println(err)
}
}()
// callback handler
go func() {
defer wg.Done()
// anonymous callbacks will not be handled
if cui.cu.User != auth.Anonymous {
if err := stats.Callback(cui.ctx, cui.cu); err != nil {
c.L.Error.Println(err)
}
}
}()
wg.Wait()
}

```

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: b5a4b96ab4efc170332a76953fe541405f18b46d

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with core/core.go lines 67-96 and inspect how the range-loop value is used by the two goroutines. Compare that behavior with the analyzer report, then determine whether the finding represents a bug, mitigated case, or desirable behavior and leave the corresponding reaction on the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.