github-vet / github-vet/rangeloop-pointer-findings
cgrates/cgrates: engine/thresholds.go; 20 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cgrates/cgrates](https://www.github.com/cgrates/cgrates) at [engine/thresholds.go](https://github.com/cgrates/cgrates/blob/fd090f5b36bf39eaf7f4c594ae11e7940f74c168/engine/thresholds.go#L107-L126)
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 actionSetID used in defer or goroutine at line 119
[Click here to see the code in its original context.](https://github.com/cgrates/cgrates/blob/fd090f5b36bf39eaf7f4c594ae11e7940f74c168/engine/thresholds.go#L107-L126)
Click here to show the 20 line(s) of Go which triggered the analyzer.
```go
for _, actionSetID := range t.tPrfl.ActionIDs {
at := &ActionTiming{
Uuid: utils.GenUUID(),
ActionsID: actionSetID,
ExtraData: args.CGREventWithOpts,
}
if tntAcnt != utils.EmptyString {
at.accountIDs = utils.NewStringMap(tntAcnt)
}
if t.tPrfl.Async {
go func() {
if errExec := at.Execute(nil, nil); errExec != nil {
utils.Logger.Warning(fmt.Sprintf(" failed executing actions: %s, error: %s", actionSetID, errExec.Error()))
}
}()
} else if errExec := at.Execute(nil, nil); errExec != nil {
utils.Logger.Warning(fmt.Sprintf(" failed executing actions: %s, error: %s", actionSetID, errExec.Error()))
err = utils.ErrPartiallyExecuted
}
}
```
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: fd090f5b36bf39eaf7f4c594ae11e7940f74c168
Contributor guide
No contributing guide indexed for this repository
Research direction
Inspect engine/thresholds.go at commit fd090f5b36bf39eaf7f4c594ae11e7940f74c168, especially lines 107-126 and the asynchronous closure. Determine whether actionSetID is incorrectly captured by the goroutine and whether the warning can report the wrong action. Done means classifying the analyzer finding as a bug, mitigated, or desirable behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100