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
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.validatorsInfois written bySetEpochValidatorsInfo(sharding/nodesCoordinator.go:714, including its old-epoch delete loop) and read bygetEpochValidatorsInfo(:740), called fromEpochStartPrepareon the epoch-start notifier goroutine, with no mutex guarding the map.SetEpochValidatorsInfocan 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