Skip to content

Data race on BlockChain state sync field between writeBlockAndSetHead and SetStateSync #1728

@praetoriansentry

Description

@praetoriansentry

Concurrent access to BlockChain's state sync field at address 0x00c0010f23e0. Read occurs in writeBlockAndSetHead (blockchain.go:2110) while write happens in SetStateSync (blockchain_reader.go:544) during block finalization. Race between worker's resultLoop and mainLoop goroutines.

8509ba2

INFO [08-28|00:45:08.256] Sealing out-of-turn                      number=1 hash=0x2aa3640      wiggle-in-sec=4,000,000,000 wiggle=4s in-turn-signer=0x97538585a02A3f1B1297EB9979cE1b34ff953f1E
INFO [08-28|00:45:08.256] Sealing successful                       number=1 delay=-255.953371ms headerDifficulty=1
==================
WARNING: DATA RACE
Read at 0x00c0010f23e0 by goroutine 102:
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /var/lib/bor/core/blockchain.go:2110 +0x4b1
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /var/lib/bor/core/blockchain.go:2057 +0x1b9
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /var/lib/bor/miner/worker.go:864 +0x1859
  github.com/ethereum/go-ethereum/miner.newWorker.gowrap3()
      /var/lib/bor/miner/worker.go:356 +0x33

Previous write at 0x00c0010f23e0 by goroutine 100:
  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

Goroutine 102 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /var/lib/bor/miner/worker.go:356 +0x11c4
  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 100 (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

{
  "IPT_bytes_out": 15737088,
  "output_text": "WARNING: DATA RACE",
  "source": {
    "container": "l2-el-2-bor-heimdall-v2-validator--50834359649948f29f06d6c8688aad9d",
    "name": "l2-el-2-bor-heimdall-v2-validator--50834359649948f29f06d6c8688aad9d",
    "stream": "error"
  },
  "moment": {
    "input_hash": "2317481170123982943",
    "_vtime_ticks": 654090846784,
    "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