Skip to content

Data race 2 via tx_pool #25870

Closed
Closed
@holiman

Description

@holiman

Detected via travis cron

WARNING: DATA RACE

Write at 0x00c000012778 by goroutine 87:

  sync/atomic.CompareAndSwapInt32()
      /home/travis/.gimme/versions/go1.19.1.linux.amd64/src/runtime/race_amd64.s:310 +0xb
  sync/atomic.CompareAndSwapInt32()
      <autogenerated>:1 +0x1e
  github.com/ethereum/go-ethereum/core.(*txNoncer).get()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/core/tx_noncer.go:48 +0x64
  github.com/ethereum/go-ethereum/core.(*TxPool).Nonce()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/core/tx_pool.go:466 +0x10f
  github.com/ethereum/go-ethereum/miner.(*testWorkerBackend).newRandomTx()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/miner/worker_test.go:194 +0x7d
  github.com/ethereum/go-ethereum/miner.testGenerateBlockAndImport()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/miner/worker_test.go:251 +0x8b7
  github.com/ethereum/go-ethereum/miner.TestGenerateBlockAndImportEthash()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/miner/worker_test.go:210 +0x30
  testing.tRunner()
      /home/travis/.gimme/versions/go1.19.1.linux.amd64/src/testing/testing.go:1446 +0x216
  testing.(*T).Run.func1()
      /home/travis/.gimme/versions/go1.19.1.linux.amd64/src/testing/testing.go:1493 +0x47

Previous write at 0x00c000012778 by goroutine 111:
  github.com/ethereum/go-ethereum/core.newTxNoncer()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/core/tx_noncer.go:37 +0xd64
  github.com/ethereum/go-ethereum/core.(*TxPool).reset()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/core/tx_pool.go:1291 +0xe1e
  github.com/ethereum/go-ethereum/core.(*TxPool).runReorg()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/core/tx_pool.go:1155 +0x373
  github.com/ethereum/go-ethereum/core.(*TxPool).scheduleReorgLoop.func2()
      /home/travis/gopath/src/github.com/ethereum/go-ethereum/core/tx_pool.go:1084 +0x71
func (txn *txNoncer) get(addr common.Address) uint64 {
	// We use mutex for get operation is the underlying
	// state will mutate db even for read access.
	txn.lock.Lock()                       <--- THIS LINE
	defer txn.lock.Unlock()
// newTxNoncer creates a new virtual state database to track the pool nonces.
func newTxNoncer(statedb *state.StateDB) *txNoncer {
	return &txNoncer{                      //  <--- PREVIOUS WRITE
		fallback: statedb.Copy(),
		nonces:   make(map[common.Address]uint64),
	}
}

Activity

added a commit that references this issue on Sep 26, 2022
4d70b6b
added a commit that references this issue on Sep 26, 2022
e004e7d
added a commit that references this issue on Oct 3, 2022
84f76ca
added a commit that references this issue on Oct 3, 2022
256877b
added a commit that references this issue on Nov 4, 2022
c702b48
added a commit that references this issue on Nov 16, 2022
60ce55a
added a commit that references this issue on Jun 6, 2023
69895ea

90 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Data race 2 via tx_pool · Issue #25870 · ethereum/go-ethereum