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

pyln-testing: wait for listen port release before starting a node

Public commit record

What the developer wrote

Authored by Ken Sedgwick

91/100 · Strong
pyln-testing: wait for listen port release before starting a node

A node's connectd is a separate process holding the listen socket,
and on shutdown it exits on its own schedule after lightningd itself
is gone -- under valgrind, its teardown can lag by tens of seconds.
If a test restarts the node in that window, the new connectd fails
with 'Address already in use', lightningd exits, and the test times
out waiting for 'Server started with public key'. Seen in CI in
test_emergencyrecoverpenaltytxn, where the port was still held 37
seconds after the old connectd began shutting down.

The filesystem port locks don't cover this: they keep other workers
from reserving the port, but the restarting node owns its reservation
both times; nothing waits for the old connectd to actually release
the socket.

Before launching lightningd, bind-probe the node's port (with
SO_REUSEADDR, matching connectd, so TIME_WAIT sockets don't count as
in use) and only proceed once the bind succeeds.

Fixes: #9354
Changelog-None
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a testing-framework fix, not a fix in the Core Lightning node software itself. It stops automated tests from failing when a background process (connectd) is slow to release a network port after a node restart. There is no direct security vulnerability being patched; it improves test reliability.

Recommended action

No security action required. Treat as a normal reliability improvement for the test suite. Reviewers can verify the bind-probe uses SO_REUSEADDR and only raises on unexpected errors.

Security signals we found

01

No security-relevant code change in production daemon

02

Fixes a test-framework race condition, not an exploit primitive

03

No input validation, cryptography, or authorization changes

04

No memory safety, parsing, or protocol changes

Risk score

Why this scored 17/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 2/15
Confidence 9/10
Evidence quality 4/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.