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

Ch4r1l3/cFuzz: master/server/service/task_check.go; 24 LoC

Open
#15,943 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 [Ch4r1l3/cFuzz](https://www.github.com/Ch4r1l3/cFuzz) at [master/server/service/task_check.go](https://github.com/Ch4r1l3/cFuzz/blob/6ded4e7c1f7ce46f7c6fc29b3d8f690a8df4dde0/master/server/service/task_check.go#L25-L48)

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 task used in defer or goroutine at line 29

[Click here to see the code in its original context.](https://github.com/Ch4r1l3/cFuzz/blob/6ded4e7c1f7ce46f7c6fc29b3d8f690a8df4dde0/master/server/service/task_check.go#L25-L48)

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

```go
for _, task := range tasks {
//logger.Logger.Debug("checkTasks")
if task.Status == models.TaskStarted && task.StatusUpdateAt+config.KubernetesConf.MaxStartTime < time.Now().Unix() {
go func() {
logger.Logger.Error("deployment start too long", "start", task.StatusUpdateAt, "now", time.Now().Unix())
SetTaskError(task.ID, "deployment start waste to much time")
}()
} else if task.Status == models.TaskRunning && time.Now().Unix()-task.StartedAt > int64(task.Time) {
go func() {
SetTaskStopped(task.ID)
}()
} else if task.Status == models.TaskRunning {
if activeRoutineNum[task.ID] == nil {
activeRoutineNum[task.ID] = new(int32)
}
if *activeRoutineNum[task.ID] == 0 {
atomic.AddInt32(activeRoutineNum[task.ID], 1)
ants.Submit(func() {
checkSingleTask(task.ID)
})
}
}

}

```

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: 6ded4e7c1f7ce46f7c6fc29b3d8f690a8df4dde0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.