Skip to content

Data race on witness manager map during concurrent read/write operations #1751

@praetoriansentry

Description

@praetoriansentry

A data race occurs in the witness manager component when a map structure is accessed concurrently without synchronization. The race happens at memory location 0x00c0011c24e0 between:

  • Read path: The witness manager's main loop() function is reading from a map (likely iterating or checking entries)
  • Write path: The handleFilterResult() function is modifying the same map via runtime.mapassign() when processing filtered witness results from the block fetcher

This race condition manifests when:

  1. The witness manager loop is actively processing or checking witness data
  2. Simultaneously, the block fetcher is handling filter results and updating witness entries

The concurrent access to the map without proper mutex protection can lead to map corruption, panics, or inconsistent witness validation state. Go maps are not safe for concurrent use when at least one goroutine is writing. This requires adding mutex synchronization around all map operations in the witness manager, or using a concurrent-safe map implementation.

702434e

==================
WARNING: DATA RACE
Read at 0x00c0011c24e0 by goroutine 198:
  github.com/ethereum/go-ethereum/eth/fetcher.(*witnessManager).loop()
      /var/lib/bor/eth/fetcher/witness_manager.go:215 +0xac5
  github.com/ethereum/go-ethereum/eth/fetcher.(*witnessManager).start.gowrap2()
      /var/lib/bor/eth/fetcher/witness_manager.go:142 +0x33

Previous write at 0x00c0011c24e0 by goroutine 196:
  runtime.mapassign()
      /usr/local/go/src/internal/runtime/maps/runtime_swiss.go:191 +0x0
  github.com/ethereum/go-ethereum/eth/fetcher.(*witnessManager).handleFilterResult()
      /var/lib/bor/eth/fetcher/witness_manager.go:878 +0x1193
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).loop()
      /var/lib/bor/eth/fetcher/block_fetcher.go:855 +0x657c
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).Start.gowrap1()
      /var/lib/bor/eth/fetcher/block_fetcher.go:298 +0x33

Goroutine 198 (running) created at:
  github.com/ethereum/go-ethereum/eth/fetcher.(*witnessManager).start()
      /var/lib/bor/eth/fetcher/witness_manager.go:142 +0x144
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).Start()
      /var/lib/bor/eth/fetcher/block_fetcher.go:299 +0xad
  github.com/ethereum/go-ethereum/eth.(*chainSyncer).loop()
      /var/lib/bor/eth/sync.go:93 +0x108
  github.com/ethereum/go-ethereum/eth.(*handler).Start.gowrap3()
      /var/lib/bor/eth/handler.go:576 +0x33

Goroutine 196 (running) created at:
  github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).Start()
      /var/lib/bor/eth/fetcher/block_fetcher.go:298 +0x8a
  github.com/ethereum/go-ethereum/eth.(*chainSyncer).loop()
      /var/lib/bor/eth/sync.go:93 +0x108
  github.com/ethereum/go-ethereum/eth.(*handler).Start.gowrap3()
      /var/lib/bor/eth/handler.go:576 +0x33
==================

{
  "IPT_bytes_out": 41345976,
  "output_text": "WARNING: DATA RACE",
  "source": {
    "container": "l2-el-6-bor-heimdall-v2-rpc--113f63384dde46c5a8409023a15d0047",
    "name": "l2-el-6-bor-heimdall-v2-rpc--113f63384dde46c5a8409023a15d0047",
    "stream": "error"
  },
  "moment": {
    "input_hash": "3247386931427725416",
    "_vtime_ticks": 2218803012205,
    "session_id": "387aac0404473becedb39ef62b17f934-37-2"
  }
}

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