Listeners can't be stopped, so bitcoin-node can hang after shutdown when an IPC client reconnects
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- cpp
- 領域
- backend, networking
調査の方向性
Start with include/mp/proxy-io.h around ListenConnections and _Listen, then read the linked review discussion for the listener stop behavior. The proposed change also requires updates to Bitcoin Core's src/ipc/capnp/protocol.cpp and coordination with #361 and #384, which affect the same accept loop. Done means listener stop prevents new connections from being served, with coverage in listen_tests.cpp and a Bitcoin Core shutdown reconnect test.
索引モデルが issue の本文から書いたものです。
説明
bitcoin/bitcoin#36585 reports a v32.0rc3 node that hit a fatal error, logged "Shutdown done", and then stayed alive for 5.7 hours until systemd killed it. The threads left were the main thread (b-shutoff) and two b-capnp-loop threads, and a mining client was connected over IPC. The report has no backtrace, so the cause of that hang is not confirmed, but the code allows this sequence:
Shutdown()callsdisconnectIncoming(), which closes the IPC connections that exist at that moment.- Nothing stops the listeners.
ListenConnectionsreturnsvoid, so Bitcoin Core'sCapnpProtocol::listen()has no handle to stop, and_Listenkeeps anaccept()pending. - A client that reconnects, as a mining client does when its connection drops, is accepted and served. Each
Connectionholds anEventLoopRef. - After "Shutdown done",
~CapnpProtocolreleases its own reference and joins the event loop thread, which runs until no references remain. It waits for as long as the new client stays connected. SIGTERM does nothing at that point, since shutdown has already run.
Proposed change
- libmultiprocess:
ListenConnectionsreturns theListener(or a handle to it), and a stop call, run on the event loop thread, prevents further accepts. After stopping, a pendingaccept()that completes is not served, and disconnect callbacks do not resume accepting at the connection limit. This was suggested in the #269 review. Closing the listening socket on stop would also make clients get "connection refused" instead of waiting in the backlog. - Bitcoin Core:
CapnpProtocolkeeps the handles fromlisten()and stops them at the start ofdisconnectIncoming(), before closing the current connections. - Tests: a
listen_tests.cppcase that stops a listener and checks that a later client is not served, including at the connection limit, and a Bitcoin Core functional test that reconnects an IPC client right after shutdown disconnects it and checks that the process exits.
The stop logic has to be tested together with the accept-retry fix in #384 and the connection-limit fix in #361, which change the same accept loop.
Origin
The window was opened by bitcoin/bitcoin#32345 ("ipc: Handle unclean shutdowns better", 2025, first released in v30.0). Before it, shutdown waited for every IPC client to disconnect on its own, so a connected client could block shutdown indefinitely. bitcoin/bitcoin@7f65aac78b95 made shutdown disconnect clients instead, but did not stop new ones from connecting, because the library has no way to stop a listener. bitcoin/bitcoin#35932 lists "new connections can still be accepted during shutdown" as a known limitation. Releases from v30.0 on are affected.
The missing stop operation was also reported privately in an independent security review (2026-08-16), at the time as an API gap with no effect on Bitcoin Core.
Links
- ipcbugs pages: https://ipcbugs.ofsky.org/bugs/bitcoin-36585-shutdown-reconnect-hang/, https://ipcbugs.ofsky.org/audits/ar-21/
- bitcoin/bitcoin#36585 (report), bitcoin/bitcoin#32345, bitcoin/bitcoin#35932, #269, #361, #384
- 主要言語
- C++
- スター
- 62
- フォーク
- 58
- 平均マージ
- 6日 11時間
- マージ済み PR(30日)
- 7
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bitcoin-core/libmultiprocess のほかの issue
-
bug hardening
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
bitcoin-core/libmultiprocess#384 ·
メンテナーはふだん 1 日以内に返信
-
Calling an IPC object after or during destroy() makes the server use a null or freed implementation対応中かも @xyzconstant が 12 日前に担当しました。 オープンbug hardening
難易度 4/5 3〜5日 初心者へのやさしさ 40/100
bitcoin-core/libmultiprocess#378 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
bitcoin-core/libmultiprocess#329 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
bitcoin-core/libmultiprocess#328 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
bitcoin-core/libmultiprocess#284 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
bitcoin-core/libmultiprocess の issue をすべて見る
似ている issue
-
documentation enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
QuantStack/git2cpp#203 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
BaptisteHudyma/Lamp-Da#588 ·
メンテナーはふだん 1 日以内に返信
-
bug macOS networking
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
docling-project/docling-parse#448 ·
メンテナーはふだん 5 日以内に返信