common: guard ecdh() against HSM fd being non-blocking - #9402
Draft
daywalker90 wants to merge 2 commits into
Draft
common: guard ecdh() against HSM fd being non-blocking#9402daywalker90 wants to merge 2 commits into
daywalker90 wants to merge 2 commits into
Conversation
On macOS under load, connectd intermittently dies with "STATUS_FAIL_HSM_IO: No hsmd ECDH response". hsmd logs that it received WIRE_HSMD_ECDH_REQ, yet connectd's synchronous wire_sync_read() returns NULL. The only way that read fails after hsmd answered is an EAGAIN from an O_NONBLOCK HSM fd. The HSM fd is one end of a socketpair sent hsmd -> lightningd -> connectd via SCM_RIGHTS; the other end lives in hsmd's io loop, whose io_new_conn() sets O_NONBLOCK (io.c:io_new_conn -> io_fd_block(fd, false)). On macOS the flag follows the shared open file description across SCM_RIGHTS, so it can be flipped on after the one-shot setup-time io_fd_block(hsm_fd, true) added in the previous fix, re-introducing the EAGAIN. Ubuntu is unaffected because its fd semantics keep the descriptions independent. Fix ecdh() itself so it does not depend on the fd flag state: re-assert blocking at the start of every synchronous exchange, and if a non-blocking read still returns EAGAIN, poll for the response and retry instead of failing the daemon. This also hardens channeld, which uses the same ecdh()/ecdh_hsmd_setup() path. Changelog-Fixed: connectd: fix intermittent "No hsmd ECDH response" crash on macOS under load (issue ElementsProject#9060).
daywalker90
force-pushed
the
fix-websocket-macos
branch
from
August 11, 2026 13:38
119dd88 to
2b01cff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #9323