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

s111/rkv: cmd/rkvd/raftimpl/etcd/raft.go; 14 LoC

Open
#8,615 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 [s111/rkv](https://www.github.com/s111/rkv) at [cmd/rkvd/raftimpl/etcd/raft.go](https://github.com/s111/rkv/blob/dd5fc895a9b65e9a9a8dc6a1a8e5fe6ff497bce5/cmd/rkvd/raftimpl/etcd/raft.go#L279-L292)

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 entry at line 284 may start a goroutine

[Click here to see the code in its original context.](https://github.com/s111/rkv/blob/dd5fc895a9b65e9a9a8dc6a1a8e5fe6ff497bce5/cmd/rkvd/raftimpl/etcd/raft.go#L279-L292)

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

```go
for _, entry := range entries {
rmetrics.commitIndex.Set(float64(entry.Index))

switch entry.Type {
case raftpb.EntryNormal:
w.handleNormal(&entry)
case raftpb.EntryConfChange:
w.logger.WithField(
"entry", etcdraft.DescribeEntry(entry, nil),
).Warnln("Committed conf change entry")

w.handleConfChange(&entry)
}
}

```

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 {
"(maybeSnapshot, 1)" -> {}
"(New, 1)" -> {"(newClient, 1)";}
"(Get, 1)" -> {"(New, 1)";}
"(Txn, 1)" -> {"(Get, 1)";"(Put, 1)";}
"(Get, 2)" -> {"(Get, 3)";}
"(Get, 3)" -> {"(Do, 3)";}
"(Put, 1)" -> {"(Set, 4)";}
"(post, 1)" -> {}
"(handleNormal, 1)" -> {"(Apply, 1)";}
"(Apply, 1)" -> {"(Range, 2)";"(Put, 2)";"(Txn, 1)";"(Alarm, 1)";"(DeleteRange, 2)";"(Compaction, 1)";"(maybeSnapshot, 1)";"(applyStore, 2)";}
"(Put, 2)" -> {"(Get, 1)";"(Range, 3)";"(processRaftRequest, 2)";}
"(add, 1)" -> {"(newWatchBroadcasts, 1)";"(post, 1)";"(newWatchBroadcast, 3)";}
"(Compaction, 1)" -> {"(Range, 3)";}
"(processRaftRequest, 2)" -> {"(Register, 1)";}
"(Register, 1)" -> {"(Set, 4)";}
"(applyStore, 2)" -> {"(Init, 1)";"(Get, 1)";}
"(newClient, 1)" -> {}
"(Range, 3)" -> {"(Get, 2)";}
"(Do, 3)" -> {}
"(DeleteRange, 2)" -> {"(Range, 3)";}
"(Set, 4)" -> {"(add, 1)";}
"(newWatchBroadcast, 3)" -> {}
"(Init, 1)" -> {"(New, 1)";}
"(Range, 2)" -> {"(Get, 1)";"(Range, 3)";}
"(Alarm, 1)" -> {"(Get, 1)";}
"(newWatchBroadcasts, 1)" -> {}
}

```

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

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.