AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 49 Bitcoin

connectd: fix race where last msg can still get lost.

Public commit record

What the developer wrote

Authored by Rusty Russell

73/100 · Adequate
connectd: fix race where last msg can still get lost.

openingd sends an ERROR, and exits. lightningd tells us to
disconnect. We read from lightningd first, and don't read from
openingd.

We need to drain subds when we're told to disconnect.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This patch fixes a timing bug in Core Lightning's connection handler. When a sub-process (like openingd) sends an error message and exits, and the main daemon simultaneously asks connectd to disconnect, connectd could previously read the disconnect order first and never read the final error message from the sub-process. The fix makes connectd first drain any remaining messages from sub-processes before closing the peer connection, so the last message is not lost.

Recommended action

Review and merge if not already deployed. Monitor for any regressions in disconnect behavior or subd cleanup timing. Consider whether the 5-second timeout is adequate under load.

Security signals we found

01

Race condition in message handling during peer disconnect

02

Potential loss of final ERROR/warning messages from subdaemons

03

New explicit two-phase drain state machine for subds then peer socket

04

Addition of per-subd timeout and logging for forced subd close

05

Test updated to expect 'Subd did not close, forcing close' log line

Risk score

Why this scored 49/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 9/15
Affected reach 10/15
Confidence 7/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.