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

rahafrouz/distributed-screenshot: worker/worker.go; 13 LoC

Open
#14,246 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 [rahafrouz/distributed-screenshot](https://www.github.com/rahafrouz/distributed-screenshot) at [worker/worker.go](https://github.com/rahafrouz/distributed-screenshot/blob/c35afd773fd0d27c384c3603fe379e908da2e1a6/worker/worker.go#L99-L111)

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 d used in defer or goroutine at line 102

[Click here to see the code in its original context.](https://github.com/rahafrouz/distributed-screenshot/blob/c35afd773fd0d27c384c3603fe379e908da2e1a6/worker/worker.go#L99-L111)

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

```go
for d := range msgs {
go func() {
// Main Loop of the Program. First handle the job
resultLocation, _ := w.handleJobRequest(d)

//And the publish the response to the requester!
w.PublishResponse(resultLocation, d)

// Ack means that this job won't be delivered to any other worker
d.Ack(false)
}()

}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in worker/worker.go at lines 99-111 and read the surrounding worker loop, including handleJobRequest and PublishResponse. Check how the goroutine uses the range-loop message and how acknowledgements are handled; done means the analyzer finding is addressed without changing the intended per-message processing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.