Skip to content

dash-spv: the peer reader can block forever writing a ping or a pong #1238

Closed

Description

@xdustinface

All paths are under dash-spv/src/ at 8dde9d0c (dev after #902).

The keepalive ping write (network/peer.rs:463) and the pong write (network/peer.rs:491-498) run after the reader's select! has resolved, with no WRITE_TIMEOUT, so the cancellation token is no longer polled. The writer is an Arc<Mutex<OwnedWriteHalf>> shared with PeerHandle::send, and the parked reader holds the lock. A kick or close() only cancels the token, so the reader task keeps the socket open, Disconnected is never sent, and every send to that peer times out on the lock.

Evidence. A throwaway test with a fake loopback peer that completes the handshake, floods pings and never reads:

fake peer has written 2162688 bytes of pings, reader read 565229
after close(): reader ended = false within 5.001496s
after the remote closes its socket: reader ended = true within 1.001084ms

Against an honest dashd the leak ends after Core's own inactivity timeout (about 20 minutes). A peer that keeps the connection open on purpose makes it permanent.

Fix. Put both writes under the same WRITE_TIMEOUT as PeerHandle::send, or race them against the token.

Activity

  1. self-assigned this
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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