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

Andyfoo/go-xutils: xthread/xthread.go; 8 LoC

Open
#15,180 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [Andyfoo/go-xutils](https://www.github.com/Andyfoo/go-xutils) at [xthread/xthread.go](https://github.com/Andyfoo/go-xutils/blob/2ae54c624cca05de6b575f3a20c688e1cd75a18e/xthread/xthread.go#L52-L59)

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 fun1 used in defer or goroutine at line 57

[Click here to see the code in its original context.](https://github.com/Andyfoo/go-xutils/blob/2ae54c624cca05de6b575f3a20c688e1cd75a18e/xthread/xthread.go#L52-L59)

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

```go
for _, fun1 := range t.taskChanFuns {
//xlog.Info("run chan task:", k)
t.waitGroup.Add(1)
go func() {
defer t.waitGroup.Done()
fun1(ch1)
}()
}

```

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: 2ae54c624cca05de6b575f3a20c688e1cd75a18e

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at xthread/xthread.go lines 52-59 and read how taskChanFuns and the goroutine are used. Check whether the reported range-loop capture can affect execution, then look for existing tests or run a focused reproduction. Done means the analyzer finding is classified as a bug, mitigated, or desirable behavior with evidence from the code.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.