github-vet / github-vet/rangeloop-pointer-findings
thomasamills/Lyndon-Go: src/evaluation/evaluator.go; 13 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [thomasamills/Lyndon-Go](https://www.github.com/thomasamills/Lyndon-Go) at [src/evaluation/evaluator.go](https://github.com/thomasamills/Lyndon-Go/blob/15e29898d54599aa4e3c63cc7d88562676646c22/src/evaluation/evaluator.go#L45-L57)
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 o used in defer or goroutine at line 48
[Click here to see the code in its original context.](https://github.com/thomasamills/Lyndon-Go/blob/15e29898d54599aa4e3c63cc7d88562676646c22/src/evaluation/evaluator.go#L45-L57)
Click here to show the 13 line(s) of Go which triggered the analyzer.
```go
for _, o := range *popSet {
//Start evaluating solutions asynchronously
go func() {
factors := e.factor.Factor(o, input)
var fitness float64
if optType == constants.Maximization || optType == constants.Minimization {
fitness = float64(len(factors))
} else {
fitness = e.calculateStdDev(&factors)
}
responseChannel <- data.OrderingFitnessValue{Ordering: &o, Fitness: fitness}
}()
}
```
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: 15e29898d54599aa4e3c63cc7d88562676646c22
Contributor guide
No contributing guide indexed for this repository
Research direction
Read src/evaluation/evaluator.go lines 45-57 and review Go range-loop capture behavior in the goroutine. Check whether each goroutine observes the intended o value and whether the pointer sent through responseChannel remains valid. Done means classifying the finding as Bug, Mitigated, or Desirable Behavior with a supported conclusion.
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
- Mostly clear
- Newbie friendliness
- 35/100