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

control-center/serviced: facade/zkapi.go; 8 LoC

Open
#18,421 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 [control-center/serviced](https://www.github.com/control-center/serviced) at [facade/zkapi.go](https://github.com/control-center/serviced/blob/61e9f80b20a46ac68d443636fc058107095e4e8f/facade/zkapi.go#L984-L991)

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 c at line 987 may start a goroutine

[Click here to see the code in its original context.](https://github.com/control-center/serviced/blob/61e9f80b20a46ac68d443636fc058107095e4e8f/facade/zkapi.go#L984-L991)

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

```go
for _, c := range clients {
_, exists := currentClientsMap[c.IPAddr]
if delete && exists {
updateDfsClientInTransaction(tx, &c, delete)
} else if !delete && !exists {
updateDfsClientInTransaction(tx, &c, delete)
}
}

```

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 {
"(Stat, 2)" -> {"(Do, 3)";}
"(Do, 3)" -> {}
"(updateDfsClientInTransaction, 3)" -> {"(Create, 2)";}
"(Create, 2)" -> {"(Stat, 2)";}
}

```

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: 61e9f80b20a46ac68d443636fc058107095e4e8f

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with facade/zkapi.go lines 984-991 and inspect updateDfsClientInTransaction, then follow the analyzer's Create, Stat, and Do call path. Determine whether passing the range variable reference can cause incorrect behavior or goroutine-related risk, and classify the finding as Bug, Mitigated, or Desirable Behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.