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

chainlighting/xPipeline: core/producer.go; 17 LoC

Open
#17,949 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 [chainlighting/xPipeline](https://www.github.com/chainlighting/xPipeline) at [core/producer.go](https://github.com/chainlighting/xPipeline/blob/de21246abec646091e34795b7a0d1539e40d5013/core/producer.go#L458-L474)

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 msg used in defer or goroutine at line 464

[Click here to see the code in its original context.](https://github.com/chainlighting/xPipeline/blob/de21246abec646091e34795b7a0d1539e40d5013/core/producer.go#L458-L474)

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

```go
for msg := range prod.messages {
// handleMessage may block. To be able to exit this method we need to
// call it async and wait for it to finish.
flushWorker.Inc()
go func() {
defer flushWorker.Done()
handleMessage(msg)
}()

if !flushWorker.WaitFor(prod.shutdownTimeout) {
Log.Warning.Printf("A producer listening to %s has found to be blocking during close. Dropping remaining messages.", StreamRegistry.GetStreamName(prod.Streams()[0]))
for msg := range prod.messages {
prod.Drop(msg)
}
return false // ### return, timed out ###
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Read core/producer.go around lines 458-474, then inspect how the range variable msg is used by the goroutine and compare the analyzer finding with the project’s intended behavior. Classify the finding by leaving the appropriate reaction: Bug, Mitigated, or Desirable Behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.