Skip to content

nodesCoordinator.validatorsInfo map is read and written without synchronization (latent data race) #122

Description

@MathijsBok

Context

Flagged twice by independent review passes during the pre-push audit of the #116 branch. Pre-existing behavior, untouched by that PR.

Problem

ihgs.validatorsInfo is written by SetEpochValidatorsInfo (sharding/nodesCoordinator.go:714, including its old-epoch delete loop) and read by getEpochValidatorsInfo (:740), called from EpochStartPrepare on the epoch-start notifier goroutine, with no mutex guarding the map. SetEpochValidatorsInfo can be called from processing goroutines while the notifier fans out, so concurrent map read/write is reachable and would panic the node (CWE-362).

The race detector has not tripped on it in unit tests because tests drive both sides sequentially.

Task

Guard the map with a mutex (a dedicated one, or document why an existing coordinator lock is the right scope), and add a concurrent regression test (SetEpochValidatorsInfo racing EpochStartPrepare under -race).

References

  • sharding/nodesCoordinator.go:714 (writer), :740 (reader), EpochStartPrepare call site

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions