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

elastos/Elastos.ELA.SideChain.ETH: dpos/dispatcher.go; 3 LoC

Open
#15,656 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 [dpos/dispatcher.go](https://github.com/elastos/Elastos.ELA.SideChain.ETH/blob/c67c967d0a3c38a528bf44a7874954a8b7b4e4bf/dpos/dispatcher.go#L383-L385)

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 v at line 384 may start a goroutine

[Click here to see the code in its original context.](https://github.com/elastos/Elastos.ELA.SideChain.ETH/blob/c67c967d0a3c38a528bf44a7874954a8b7b4e4bf/dpos/dispatcher.go#L383-L385)

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

```go
for _, v := range status.PendingProposals {
d.setProcessingProposal(&v)
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in dpos/dispatcher.go at the loop around lines 383-385 and trace setProcessingProposal, including the ProcessVote paths shown by the analyzer. Check whether the address of the range variable can escape into a goroutine and identify the project’s relevant tests or validation commands. Done means the reported finding is confirmed and addressed, or documented as safe, with validation completed.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.