Skip to content

Data race on BlockChain state sync field between SetStateSync writer and insertChainWithWitnesses reader #1731

@praetoriansentry

Description

@praetoriansentry

Concurrent access to state sync field at 0x00c0011bd460. Write occurs in SetStateSync (blockchain_reader.go:544) during block finalization while read happens in insertChainWithWitnesses (blockchain.go:2710) during chain insertion. Race between miner worker and block fetcher import goroutines.

8509ba2

==================
WARNING: DATA RACE
Write at 0x00c0011bd460 by goroutine 103:
  github.com/ethereum/go-ethereum/core.(*BlockChain).SetStateSync()
      /var/lib/bor/core/blockchain_reader.go:544 +0x44
  github.com/ethereum/go-ethereum/consensus/bor.(*Bor).FinalizeAndAssemble()
      /var/lib/bor/consensus/bor/bor.go:1110 +0x983
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /var/lib/bor/miner/worker.go:1634 +0x2c4
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /var/lib/bor/miner/worker.go:1584 +0x94f
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /var/lib/bor/miner/worker.go:640 +0x958
  github.com/ethereum/go-ethereum/miner.newWorker.gowrap1()
      /var/lib/bor/miner/worker.go:354 +0x33

Previous read at 0x00c0011bd460 by goroutine 391:
  github.com/ethereum/go-ethereum/core.(*BlockChain).insertChainWithWitnesses()
      /var/lib/bor/core/blockchain.go:2710 +0x4aca
  github.com/ethereum/go-ethereum/core.(*BlockChain).InsertChainWithWitnesses()
      /var/lib/bor/core/blockchain.go:2185 +0x1212
  github.com/ethereum/go-ethereum/eth.newHandler.func3()
      /var/lib/bor/eth/handler.go:274 +0x5bd
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).importBlocks.func1()
      /var/lib/bor/eth/fetcher/block_fetcher.go:1223 +0xa71

Goroutine 103 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /var/lib/bor/miner/worker.go:354 +0x10d4
  github.com/ethereum/go-ethereum/miner.New()
      /var/lib/bor/miner/miner.go:97 +0x104
  github.com/ethereum/go-ethereum/eth.New()
      /var/lib/bor/eth/backend.go:386 +0x47a4
  github.com/cockroachdb/pebble.Open.setCurrentFunc.func9()
      /go/pkg/mod/github.com/cockroachdb/pebble@v1.1.2/version_set.go:888 +0x85
  github.com/cockroachdb/pebble.(*versionSet).create()
      /go/pkg/mod/github.com/cockroachdb/pebble@v1.1.2/version_set.go:187 +0x711
  github.com/cockroachdb/pebble.(*versionSet).create()
      /go/pkg/mod/github.com/cockroachdb/pebble@v1.1.2/version_set.go:181 +0x597
  github.com/cockroachdb/pebble.(*versionSet).create()
      /go/pkg/mod/github.com/cockroachdb/pebble@v1.1.2/version_set.go:176 +0x444
  github.com/cockroachdb/pebble.Open()
      /go/pkg/mod/github.com/cockroachdb/pebble@v1.1.2/open.go:263 +0x262c
  github.com/ethereum/go-ethereum/ethdb/pebble.New()
      /var/lib/bor/ethdb/pebble/pebble.go:245 +0xe04
  github.com/ethereum/go-ethereum/node.newPebbleDBDatabase()
      /var/lib/bor/node/database.go:116 +0x90
  github.com/ethereum/go-ethereum/node.openKeyValueDatabase()
      /var/lib/bor/node/database.go:91 +0x244
  github.com/ethereum/go-ethereum/node.openDatabase()
      /var/lib/bor/node/database.go:57 +0x57
  github.com/ethereum/go-ethereum/node.(*Node).OpenDatabaseWithFreezer()
      /var/lib/bor/node/node.go:817 +0x437
  github.com/ethereum/go-ethereum/eth.New()
      /var/lib/bor/eth/backend.go:151 +0x939
  github.com/ethereum/go-ethereum/internal/cli/server.NewServer()
      /var/lib/bor/internal/cli/server/server.go:208 +0x704
  github.com/ethereum/go-ethereum/internal/cli/server.(*Command).Run()
      /var/lib/bor/internal/cli/server/command.go:246 +0x24c
  github.com/mitchellh/cli.(*CLI).Run()
      /go/pkg/mod/github.com/mitchellh/cli@v1.1.5/cli.go:262 +0x68f
  github.com/ethereum/go-ethereum/internal/cli.Run()
      /var/lib/bor/internal/cli/command.go:48 +0x324
  main.main()
      /var/lib/bor/cmd/cli/main.go:12 +0x19b

Goroutine 391 (running) created at:
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).importBlocks()
      /var/lib/bor/eth/fetcher/block_fetcher.go:1193 +0x634
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).loop()
      /var/lib/bor/eth/fetcher/block_fetcher.go:529 +0x2ca4
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).Start.gowrap1()
      /var/lib/bor/eth/fetcher/block_fetcher.go:298 +0x33
==================

{
  "IPT_bytes_out": 19828200,
  "output_text": "WARNING: DATA RACE",
  "source": {
    "container": "l2-el-3-bor-heimdall-v2-validator--603ade9f602f4ab1b3036e8a6e21c4a8",
    "name": "l2-el-3-bor-heimdall-v2-validator--603ade9f602f4ab1b3036e8a6e21c4a8",
    "stream": "error"
  },
  "moment": {
    "input_hash": "-7579479045333783639",
    "_vtime_ticks": 675935760195,
    "session_id": "c0ceefcd588ee0d629772f6fd9eae1ec-36-12"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions