Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miner: Data race in TestGenerateBlockAndImportEthash #24299

Closed
piersy opened this issue Jan 26, 2022 · 2 comments
Closed

miner: Data race in TestGenerateBlockAndImportEthash #24299

piersy opened this issue Jan 26, 2022 · 2 comments
Labels

Comments

@piersy
Copy link
Contributor

piersy commented Jan 26, 2022

System information

Geth version: geth version

Geth
Version: 1.10.16-unstable
Git Commit: 015fde9a2c4b6e722a9de5bfea2a14226806a231
Git Commit Date: 20220125
Architecture: amd64
Go Version: go1.17.6
Operating System: darwin
GOPATH=
GOROOT=go

OS & Version: OSX

Expected behaviour

The test passes.

Actual behaviour

The test fails due to data races.

Steps to reproduce the behaviour

go test -p 1 -race ./miner -run TestGenerateBlockAndImportEthash

Backtrace

```
==================
WARNING: DATA RACE
Write at 0x00c0000f0c48 by goroutine 37:
  github.com/ethereum/go-ethereum/trie.(*Trie).hashRoot()
      /Users/piersy/projects/go-ethereum/trie/trie.go:581 +0x193
  github.com/ethereum/go-ethereum/trie.(*Trie).Hash()
      /Users/piersy/projects/go-ethereum/trie/trie.go:520 +0x4b
  github.com/ethereum/go-ethereum/trie.(*SecureTrie).Hash()
      /Users/piersy/projects/go-ethereum/trie/secure_trie.go:183 +0x44
  github.com/ethereum/go-ethereum/core/state.(*StateDB).IntermediateRoot()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:880 +0x9b2
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:905 +0xa4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0000f0c48 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:651 +0x94
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c0000f0c38 by goroutine 37:
  github.com/ethereum/go-ethereum/trie.(*Trie).Hash()
      /Users/piersy/projects/go-ethereum/trie/trie.go:521 +0x75
  github.com/ethereum/go-ethereum/trie.(*SecureTrie).Hash()
      /Users/piersy/projects/go-ethereum/trie/secure_trie.go:183 +0x44
  github.com/ethereum/go-ethereum/core/state.(*StateDB).IntermediateRoot()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:880 +0x9b2
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:905 +0xa4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0000f0c38 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:651 +0x94
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c0000f0cc0 by goroutine 37:
  github.com/ethereum/go-ethereum/trie.(*SecureTrie).Commit()
      /Users/piersy/projects/go-ethereum/trie/secure_trie.go:174 +0x2f9
  github.com/ethereum/go-ethereum/core/state.(*stateObject).CommitTrie()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:405 +0x1c2
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:918 +0x584
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0000f0cc0 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*stateObject).deepCopy()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:450 +0x1d8
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:689 +0xf44
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c0000f0c98 by goroutine 37:
  github.com/ethereum/go-ethereum/trie.(*Trie).hashRoot()
      /Users/piersy/projects/go-ethereum/trie/trie.go:581 +0x193
  github.com/ethereum/go-ethereum/trie.(*Trie).Hash()
      /Users/piersy/projects/go-ethereum/trie/trie.go:520 +0x4b
  github.com/ethereum/go-ethereum/trie.(*Trie).Commit()
      /Users/piersy/projects/go-ethereum/trie/trie.go:536 +0xbc
  github.com/ethereum/go-ethereum/trie.(*SecureTrie).Commit()
      /Users/piersy/projects/go-ethereum/trie/secure_trie.go:177 +0x244
  github.com/ethereum/go-ethereum/core/state.(*stateObject).CommitTrie()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:405 +0x1c2
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:918 +0x584
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0000f0c98 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*stateObject).deepCopy()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:450 +0x1d8
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:689 +0xf44
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c0000f0c88 by goroutine 37:
  github.com/ethereum/go-ethereum/trie.(*Trie).Hash()
      /Users/piersy/projects/go-ethereum/trie/trie.go:521 +0x75
  github.com/ethereum/go-ethereum/trie.(*Trie).Commit()
      /Users/piersy/projects/go-ethereum/trie/trie.go:536 +0xbc
  github.com/ethereum/go-ethereum/trie.(*SecureTrie).Commit()
      /Users/piersy/projects/go-ethereum/trie/secure_trie.go:177 +0x244
  github.com/ethereum/go-ethereum/core/state.(*stateObject).CommitTrie()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:405 +0x1c2
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:918 +0x584
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0000f0c88 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*stateObject).deepCopy()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:450 +0x1d8
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:689 +0xf44
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c0003288b8 by goroutine 37:
  github.com/ethereum/go-ethereum/core/state.(*stateObject).CommitTrie()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:407 +0x21c
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:918 +0x584
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0003288b8 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:689 +0xf44
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c00034cf38 by goroutine 37:
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:926 +0x650
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c00034cf38 by goroutine 38:
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:687 +0xd64
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c0000f0c70 by goroutine 37:
  github.com/ethereum/go-ethereum/trie.(*SecureTrie).Commit()
      /Users/piersy/projects/go-ethereum/trie/secure_trie.go:174 +0x2f9
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:941 +0x90f
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c0000f0c70 by goroutine 38:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:651 +0x94
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c000416c20 by goroutine 37:
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Commit()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:915 +0x544
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockWithState()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1197 +0x9e4
  github.com/ethereum/go-ethereum/core.(*BlockChain).writeBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1270 +0xca
  github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockAndSetHead()
      /Users/piersy/projects/go-ethereum/core/blockchain.go:1263 +0x1a4
  github.com/ethereum/go-ethereum/miner.(*worker).resultLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:729 +0xf39
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·7()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0x39

Previous read at 0x00c000416c20 by goroutine 38:
  github.com/ethereum/go-ethereum/core/state.(*stateObject).deepCopy()
      /Users/piersy/projects/go-ethereum/core/state/state_object.go:457 +0x4f2
  github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy()
      /Users/piersy/projects/go-ethereum/core/state/statedb.go:689 +0xf44
  github.com/ethereum/go-ethereum/miner.(*worker).updateSnapshot()
      /Users/piersy/projects/go-ethereum/miner/worker.go:827 +0x3af
  github.com/ethereum/go-ethereum/miner.(*worker).commit()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1157 +0xcdd
  github.com/ethereum/go-ethereum/miner.(*worker).commitWork()
      /Users/piersy/projects/go-ethereum/miner/worker.go:1118 +0x257
  github.com/ethereum/go-ethereum/miner.(*worker).mainLoop()
      /Users/piersy/projects/go-ethereum/miner/worker.go:529 +0x80a
  github.com/ethereum/go-ethereum/miner.newWorker·dwrap·5()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0x39

Goroutine 37 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:290 +0xe30
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47

Goroutine 38 (running) created at:
  github.com/ethereum/go-ethereum/miner.newWorker()
      /Users/piersy/projects/go-ethereum/miner/worker.go:288 +0xd35
  github.com/ethereum/go-ethereum/miner.newTestWorker()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:205 +0x1a5
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:234 +0x446
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /Users/piersy/projects/go-ethereum/miner/worker_test.go:211 +0x30
  testing.tRunner()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/piersy/sdk/go1.17.6/src/testing/testing.go:1306 +0x47
==================
--- FAIL: TestGenerateBlockAndImportEthash (5.03s)
    testing.go:1152: race detected during execution of test
```

When submitting logs: please submit them as text and not screenshots.

@holiman
Copy link
Contributor

holiman commented Jan 27, 2022

Thanks, good catch. We need to fix this before next release. It seems to stem from #23256 (todo: we should check if it's also caught by the miner stress-test)

@holiman
Copy link
Contributor

holiman commented Feb 7, 2022

Fixed via #24349

@holiman holiman closed this as completed Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants