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

elastos/Elastos.ELA.SideChain.ETH: consensus/pbft/network.go; 3 LoC

Open
#15,654 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 [elastos/Elastos.ELA.SideChain.ETH](https://www.github.com/elastos/Elastos.ELA.SideChain.ETH) at [consensus/pbft/network.go](https://github.com/elastos/Elastos.ELA.SideChain.ETH/blob/c67c967d0a3c38a528bf44a7874954a8b7b4e4bf/consensus/pbft/network.go#L558-L560)

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 vote at line 559 may start a goroutine

[Click here to see the code in its original context.](https://github.com/elastos/Elastos.ELA.SideChain.ETH/blob/c67c967d0a3c38a528bf44a7874954a8b7b4e4bf/consensus/pbft/network.go#L558-L560)

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

```go
for _, vote := range c.Votes {
p.dispatcher.ProcessVote(&vote)
}

```

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 {
"(ProcessVote, 1)" -> {"(New, 1)";}
"(openDB, 1)" -> {}
"(reorganizeChain, 2)" -> {"(OnBlockSaved, 2)";}
"(dial, 1)" -> {"(Add, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(newClient, 1)" -> {"(Dial, 1)";}
"(New, 1)" -> {"(NewServer, 1)";"(Open, 2)";"(Subscribe, 1)";"(LoadBlockNode, 2)";"(New, 2)";"(New, 3)";"(Create, 2)";"(makeAccountManager, 1)";"(Add, 1)";}
"(UnwindBlock, 2)" -> {}
"(Get, 1)" -> {"(Do, 1)";"(Add, 2)";}
"(Send, 1)" -> {"(delete, 1)";"(Call, 3)";"(send, 2)";"(add, 2)";"(Call, 2)";}
"(Call, 5)" -> {"(run, 4)";}
"(doProtoHandshake, 1)" -> {}
"(fetchHeaders, 3)" -> {}
"(NewBlockChain, 7)" -> {"(Load, 1)";}
"(OnFilterLoad, 2)" -> {"(Load, 1)";}
"(setupConn, 3)" -> {"(doProtoHandshake, 1)";}
"(ProcessHigherBlock, 1)" -> {"(TryStartNewConsensus, 1)";}
"(OnBlockSaved, 2)" -> {"(onBlockSaved, 3)";}
"(IncreaseChainHeight, 1)" -> {}
"(dial, 2)" -> {"(Dial, 1)";"(SetupConn, 3)";"(Dial, 3)";}
"(delete, 1)" -> {"(delete, 5)";}
"(Create, 4)" -> {"(create, 5)";}
"(AccessFutureBlock, 1)" -> {}
"(create, 5)" -> {"(run, 4)";}
"(ProcessBlock, 2)" -> {"(IncreaseChainHeight, 1)";}
"(Start, 1)" -> {"(Register, 1)";"(DialInProc, 1)";"(startEthEntryUpdate, 1)";"(start, 2)";"(Start, 0)";}
"(processMessage, 1)" -> {"(OnSidechainIllegalEvidenceReceived, 1)";"(OnInactiveArbitratorsReceived, 2)";"(OnVoteAccepted, 2)";}
"(Call, 3)" -> {"(Call, 5)";}
"(fetchHeight, 1)" -> {}
"(Resolve, 1)" -> {"(RequestENR, 1)";}
"(OnConfirmReceived, 3)" -> {}
"(start, 2)" -> {}
"(DoCall, 8)" -> {}
"(retrieve, 5)" -> {"(sendReq, 3)";}
"(IngestBlock, 3)" -> {}
"(Synchronise, 4)" -> {"(synchronise, 4)";}
"(OnBlock, 2)" -> {"(OnBlockReceived, 3)";"(OnConfirmReceived, 3)";}
"(delete, 5)" -> {}
"(syncWithPeer, 3)" -> {"(fetchHeight, 1)";"(findAncestor, 2)";"(fetchHeaders, 3)";"(processFastSyncContent, 1)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(ProcessOrphans, 1)" -> {"(maybeAcceptBlock, 2)";}
"(New, 3)" -> {"(Start, 0)";"(IngestBlock, 3)";"(UnwindBlock, 2)";"(Add, 2)";"(newClientHandler, 5)";"(newClient, 1)";"(NewBlockChain, 7)";"(NewTxPool, 3)";"(synchronise, 1)";"(NewProtocolManager, 12)";"(NewLightChain, 4)";"(New, 6)";"(SubscriptEvent, 2)";"(Start, 1)";"(newRequestDistributor, 2)";}
"(run, 4)" -> {"(subMatch, 4)";}
"(onBlockSaved, 3)" -> {"(OnBlockSaved, 1)";}
"(New, 2)" -> {"(OnBlock, 2)";"(OnTxFilterLoad, 2)";"(Set, 2)";"(Get, 1)";"(Add, 1)";"(OnVersion, 2)";"(NodeAddr, 1)";"(OnFilterLoad, 2)";"(dial, 1)";}
"(OnBlockReceived, 3)" -> {}
"(newLightFetcher, 1)" -> {}
"(processFastSyncContent, 1)" -> {}
"(newRequestDistributor, 2)" -> {}
"(Load, 1)" -> {}
"(add, 2)" -> {}
"(Add, 2)" -> {"(add, 2)";}
"(OnBlockSaved, 1)" -> {"(ProcessBlock, 2)";}
"(makeAccountManager, 1)" -> {"(NewManager, 2)";}
"(synchronise, 1)" -> {"(Synchronise, 4)";}
"(blockReceived, 2)" -> {"(OnBlockReceived, 2)";}
"(ProcessBlock, 1)" -> {"(ProcessOrphans, 1)";"(maybeAcceptBlock, 1)";}
"(maybeAcceptBlock, 2)" -> {"(OnBlockSaved, 2)";}
"(DialInProc, 1)" -> {}
"(OnVoteAccepted, 2)" -> {"(tryGetCurrentProposal, 2)";}
"(StartProposal, 1)" -> {}
"(injectResponse, 4)" -> {}
"(maybeAcceptBlock, 1)" -> {"(connectBestChain, 2)";}
"(send, 2)" -> {"(retrieve, 5)";}
"(OnBlockReceived, 2)" -> {"(ProcessHigherBlock, 1)";}
"(RequestENR, 1)" -> {"(ensureBond, 2)";}
"(newSession, 2)" -> {}
"(Subscribe, 1)" -> {"(Do, 1)";}
"(New, 9)" -> {}
"(Dial, 1)" -> {"(SetupConn, 3)";}
"(sendReq, 3)" -> {}
"(findAncestor, 2)" -> {}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(subMatch, 4)" -> {"(run, 5)";}
"(SetupConn, 3)" -> {"(setupConn, 3)";}
"(NewServer, 1)" -> {"(New, 3)";}
"(SubscriptEvent, 2)" -> {"(AccessFutureBlock, 1)";}
"(jsonRPCRead, 3)" -> {}
"(sendPing, 3)" -> {"(injectResponse, 4)";}
"(Register, 1)" -> {"(NewFileChannels, 1)";}
"(sidechainIllegalEvidenceReceived, 1)" -> {"(OnSidechainIllegalEvidenceReceived, 1)";}
"(updateNode, 1)" -> {"(RequestENR, 1)";}
"(NewTxPool, 3)" -> {}
"(LoadBlockNode, 2)" -> {"(Add, 2)";}
"(newClientTransport, 6)" -> {}
"(OnVersion, 2)" -> {}
"(NewManager, 2)" -> {}
"(Open, 2)" -> {"(newSession, 2)";"(openDB, 1)";}
"(NewProtocolManager, 12)" -> {"(New, 9)";"(New, 6)";}
"(newWorker, 6)" -> {}
"(NewLightChain, 4)" -> {"(Load, 1)";}
"(run, 5)" -> {}
"(connectBestChain, 2)" -> {"(reorganizeChain, 2)";}
"(OnTxFilterLoad, 2)" -> {"(Load, 1)";}
"(newClientHandler, 5)" -> {"(newLightFetcher, 1)";"(New, 9)";}
"(Set, 2)" -> {"(Do, 1)";}
"(AppendToTxPool, 1)" -> {}
"(ensureBond, 2)" -> {"(sendPing, 3)";}
"(NodeAddr, 1)" -> {"(Load, 1)";}
"(Add, 1)" -> {"(Send, 1)";}
"(tryGetCurrentProposal, 2)" -> {}
"(run, 1)" -> {"(updateNode, 1)";}
"(New, 6)" -> {"(newWorker, 6)";}
"(Start, 0)" -> {"(jsonRPCRead, 3)";"(processMessage, 1)";"(blockReceived, 2)";"(sidechainIllegalEvidenceReceived, 1)";"(run, 1)";}
"(Create, 2)" -> {"(Create, 4)";}
"(TryStartNewConsensus, 1)" -> {"(StartProposal, 1)";"(ProcessBlock, 1)";}
"(OnInactiveArbitratorsReceived, 2)" -> {}
"(synchronise, 4)" -> {"(syncWithPeer, 3)";}
"(startEthEntryUpdate, 1)" -> {}
"(Call, 2)" -> {"(DoCall, 8)";}
"(OnSidechainIllegalEvidenceReceived, 1)" -> {"(SendSidechainIllegalEvidenceTransaction, 1)";}
"(SendSidechainIllegalEvidenceTransaction, 1)" -> {"(AppendToTxnPool, 1)";}
"(Do, 1)" -> {"(dial, 2)";"(resolve, 1)";}
"(NewFileChannels, 1)" -> {}
"(AppendToTxnPool, 1)" -> {"(AppendToTxPool, 1)";}
"(resolve, 1)" -> {"(Resolve, 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: c67c967d0a3c38a528bf44a7874954a8b7b4e4bf

Contributor guide

No contributing guide indexed for this repository

Research direction

Read consensus/pbft/network.go at lines 558-560 and inspect the ProcessVote call path described by the analyzer. Determine whether the range-loop reference can cause a real bug, a mitigated issue, or desirable behavior, then classify the finding with the corresponding reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.