dusk-network / dusk-blockchain

Reference implementation of the DUSK Network node, written in Golang
MIT License
102 stars 47 forks source link

An unsynchronized write and close of `Accumulator.verificationChan` chan #586

Closed ggoranov closed 4 years ago

ggoranov commented 4 years ago
==> /tmp/localnet-575692425/node-9001/dusk_stderr <==
==================
WARNING: DATA RACE
Read at 0x00c00118cb50 by goroutine 108:
  runtime.chansend()
      /usr/local/go/src/runtime/chan.go:142 +0x0
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus/agreement.(*Accumulator).Process()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/agreement/accumulator.go:47 +0xc8
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus/agreement.(*agreement).CollectAgreementEvent()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/agreement/agreement.go:80 +0x41b
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus/agreement.(*agreement).CollectAgreementEvent-fm()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/agreement/agreement.go:72 +0x55
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*FilteringListener).NotifyPayload()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/component.go:105 +0x21d
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*roundStore).Dispatch()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:130 +0x33f
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).flushRoundQueue()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:274 +0x119

Previous write at 0x00c00118cb50 by goroutine 47:
  runtime.closechan()
      /usr/local/go/src/runtime/chan.go:334 +0x0
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus/agreement.(*agreement).Finalize()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/agreement/accumulator.go:113 +0xc7
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*roundStore).DispatchFinalize()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:164 +0x95
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).FinalizeRound()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:374 +0x8b
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).stopConsensus()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:235 +0x38
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).StopConsensus()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:227 +0xd0
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).StopConsensus-fm()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:223 +0x55
  github.com/dusk-network/dusk-blockchain/pkg/util/nativeutils/eventbus.(*CallbackListener).Notify()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/util/nativeutils/eventbus/listener.go:31 +0x5e
  github.com/dusk-network/dusk-blockchain/pkg/util/nativeutils/eventbus.(*EventBus).Publish()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/util/nativeutils/eventbus/publisher.go:30 +0x363
  github.com/dusk-network/dusk-blockchain/pkg/core/chain.(*Chain).onAcceptBlock()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/chain/chain.go:250 +0x282
  github.com/dusk-network/dusk-blockchain/pkg/core/chain.(*Chain).onAcceptBlock-fm()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/chain/chain.go:228 +0x55
  github.com/dusk-network/dusk-blockchain/pkg/util/nativeutils/eventbus.(*CallbackListener).Notify()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/util/nativeutils/eventbus/listener.go:31 +0x5e
  github.com/dusk-network/dusk-blockchain/pkg/util/nativeutils/eventbus.(*EventBus).Publish()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/util/nativeutils/eventbus/publisher.go:30 +0x363
  github.com/dusk-network/dusk-blockchain/pkg/p2p/peer/processing/chainsync.(*ChainSynchronizer).Synchronize()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/p2p/peer/processing/chainsync/sync.go:104 +0x833
  github.com/dusk-network/dusk-blockchain/pkg/p2p/peer.(*messageRouter).route()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/p2p/peer/router.go:74 +0x402
  github.com/dusk-network/dusk-blockchain/pkg/p2p/peer.(*messageRouter).Collect()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/p2p/peer/router.go:44 +0x211
  github.com/dusk-network/dusk-blockchain/pkg/p2p/peer.(*Reader).readLoop()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/p2p/peer/peer.go:253 +0x4a6
  github.com/dusk-network/dusk-blockchain/pkg/p2p/peer.(*Reader).ReadLoop()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/p2p/peer/peer.go:209 +0x6c

Goroutine 108 (running) created at:
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).CollectRoundUpdate()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:263 +0x2bd
  github.com/dusk-network/dusk-blockchain/pkg/core/consensus.(*Coordinator).CollectRoundUpdate-fm()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/consensus/round.go:251 +0x55
  github.com/dusk-network/dusk-blockchain/pkg/util/nativeutils/eventbus.(*CallbackListener).Notify()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/util/nativeutils/eventbus/listener.go:31 +0x5e
  github.com/dusk-network/dusk-blockchain/pkg/util/nativeutils/eventbus.(*EventBus).Publish()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/util/nativeutils/eventbus/publisher.go:30 +0x363
  github.com/dusk-network/dusk-blockchain/pkg/core/chain.(*Chain).sendRoundUpdate()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/chain/chain.go:374 +0x3e3
  github.com/dusk-network/dusk-blockchain/pkg/core/chain.(*Chain).handleCertificateMessage.func1()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/pkg/core/chain/chain.go:641 +0x38

Goroutine 47 (running) created at:
  main.(*Server).OnAccept()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/cmd/dusk/server.go:193 +0x62f
  main.(*Server).OnAccept-fm()
      /home/tech/repo/dusknetwork/temp/dusk-blockchain/cmd/dusk/server.go:179 +0x55
==================
jules commented 4 years ago

Fixed via #618