Skip to content

Chain binary crashes within seconds: concurrent map read/write in Sync.handleGenericConsensusMessage #18

Description

@Hafuyya

Summary

The chain binary (hyperspace-agentic-blockchain) crashes with a Go fatal error within 10-45 seconds of connecting to peers. The crash is a data race in the transport/sync layer — unsynchronized map access in handleGenericConsensusMessage. This prevents the chain from syncing even a single block.

Tested on v1.7.4 and v1.7.8 — both affected.

Error

fatal error: concurrent map read and map write

goroutine 243 [running]:
internal/runtime/maps.fatal({0x1f4a6db?, 0xc00112fd18?})
    /home/ubuntu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.7.linux-amd64/src/runtime/panic.go:1046 +0x18
github.com/hyperspace-a1/hyperspace-edge/network.(*Sync).handleGenericConsensusMessage(0xc00028af00, ...)
    .../hyperspace-edge/network/sync.go:1757 +0x315
github.com/hyperspace-a1/hyperspace-edge/network.(*MessageRouter).Route(...)
    .../hyperspace-edge/network/protocol.go:283 +0x279
github.com/hyperspace-a1/hyperspace-edge/network.(*Sync).HandleMessage(...)
    .../hyperspace-edge/network/sync.go:647 +0x23c
github.com/hyperspace-a1/hyperspace-edge/network.(*Network).processMessage(...)
    .../hyperspace-edge/network/network.go:179 +0x39
github.com/hyperspace-a1/hyperspace-edge/network.(*Network).messageWorker(...)
    .../hyperspace-edge/network/network.go:169 +0x218

A second variant hits connectToBootnodes in transport.go with concurrent map writes.

Reproduction

  1. Install chain binary v1.7.8 (or v1.7.4)
  2. Start with --profile testnet --mine
  3. Wait 10-45 seconds for peer connections
  4. Chain crashes with fatal error: concurrent map read and map write
  5. CLI auto-restarts chain, crashes again immediately

In a 5-minute window I observed 5 consecutive crashes — the chain never synced past block 0.

Impact

  • Chain cannot sync. Zero blocks are synced before each crash.
  • Miner registration impossible. Without a synced local chain, hyperspace status shows Registered: no and Sync: unknown.
  • No block rewards. Points stay at 0.00 because the node can't participate in consensus.
  • The CLI falls back to remote RPC (boot1.a1.hyper.space:8545), but the P2P agent layer still works — inference, experiments, and training continue unaffected.

Root Cause

The Sync struct's internal maps (likely peer state or consensus message tracking) are accessed concurrently from multiple messageWorker goroutines without synchronization. In Go, concurrent map read+write is a fatal, unrecoverable runtime error.

The fix is straightforward: use sync.RWMutex around the map(s) accessed in handleGenericConsensusMessage (sync.go:1757) and connectToBootnodes (transport.go), or switch to sync.Map.

Environment

  • OS: Ubuntu 24.04, Linux 6.17.0
  • Chain binary: v1.7.4 and v1.7.8 (both affected)
  • CLI: v5.39.2
  • Go toolchain (from binary): go1.25.7
  • Role: miner
  • Chain ID: 808080 (testnet)

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