github-vet / github-vet/rangeloop-pointer-findings
csweichel/werft: pkg/werft/werft.go; 16 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [csweichel/werft](https://www.github.com/csweichel/werft) at [pkg/werft/werft.go](https://github.com/csweichel/werft/blob/3575eb263ce94724e54c3316e915553a625fae00/pkg/werft/werft.go#L213-L228)
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.
> function call which takes a reference to job at line 220 may start a goroutine
[Click here to see the code in its original context.](https://github.com/csweichel/werft/blob/3575eb263ce94724e54c3316e915553a625fae00/pkg/werft/werft.go#L213-L228)
Click here to show the 16 line(s) of Go which triggered the analyzer.
```go
for _, job := range expectedJobs {
knownStatus, exists := knownJobsIdx[job.Name]
if !exists {
log.WithField("name", job.Name).Warn("executor does not know about this job - we have missed an event. Marking as failed.")
job.Phase = v1.JobPhase_PHASE_DONE
job.Conditions.Success = false
job.Details = "Werft missed updates for this job and the job is no longer running."
srv.handleJobUpdate(nil, &job)
continue
}
if !reflect.DeepEqual(knownStatus, job) {
log.WithField("name", job.Name).Warn("executor had a different status than what we had last seen - we have missed an event. Updating job.")
srv.handleJobUpdate(nil, &job)
}
}
```
Click here to show extra information the analyzer produced.
```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(handleJobUpdate, 2)" -> {"(ensureLogging, 1)";}
"(ensureLogging, 1)" -> {}
}
```
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: 3575eb263ce94724e54c3316e915553a625fae00
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with pkg/werft/werft.go at the reported lines and inspect srv.handleJobUpdate, especially the analyzer's noted path through ensureLogging. Determine whether passing the range-loop variable reference can cause an actual goroutine-related bug in this code. Done means classifying the finding as Bug, Mitigated, or Desirable Behavior.
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