mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:08:38 +00:00
Update libmultiprocess subtree to add nonunix platform support and fix race conditions #36747
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36747
Loading…
Reference in a new issue
No description provided.
Delete branch "pr/subtree-15"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The changes can be verified by running
test/lint/git-subtree-check.sh src/ipc/libmultiprocessas described in developer notes and lint instructions.Changes since last subtree update (#35720):
CurrentThread()accessor matching compatibility code in bitcoin/bitcoin#35084 (#323) and remove code for Cap'n Proto versions before 0.9 (#331).ConnectStreamconnects, and leaks and hangs when a clientconstruct()call throws (#298).SpawnProcesscould leak into processes forked at the same time by other threads, by clearingFD_CLOEXECin the child after forking (#311).SpawnProcessreportexecfailures back to the parent and throw, reaping the child (#312).std::chrono::time_pointfields (#303) and for serializing lists of interface objects that need to be moved from (#304), both needed by bitcoin/bitcoin#10102.GCSFilter::ElementSet, needed by bitcoin/bitcoin#29409 (#379).capnptool in vcpkg and Windows builds, needed by bitcoin/bitcoin#32387 (#317).destroy_connectionoption toServeStreamandConnectStream, letsServeStreamtake ownership of the init object and return the new server and its connection, and adds anEventLoop::incomingConnections()accessor, simplifying test setup in both repositories and needed by bitcoin/bitcoin#35932 (#365).EventLoop::post()withsync()taking akj::FunctionParam, avoiding a heap allocation per call (#347).[[noreturn]]attributes for-Wmissing-noreturn(#339, for bitcoin/bitcoin#35911), and fixes-Wunused(#362, for bitcoin/bitcoin#36167),-Wunused-const-variableand-Wundef(#370), and-Wmissing-prototypes(#386, for bitcoin/bitcoin#36743) warnings.KJ_NO_EXCEPTIONS), as happens on NetBSD (#364).mpgenbinary changes (#316), fixesmpgenlink order for static Cap'n Proto builds (#367), linksmpgenagainstkj-asyncinstead ofcapnp-rpc(#327), shows Cap'n Protofind_packagediagnostics (#325), installstype-unordered-set.handversion.h(#350), and shows include-what-you-use errors instead of failing silently (#371).ListenConnections(#310),ReadListreturn value check (#338), connect test race fix (#343) and cleanups (#344),std::ranges::copyfollow-ups (#307), trailing whitespace removal (#345), Cap'n Proto version documentation fix (#357), clang-tidy updates (#358, #360, #380, #389), new CI job testing newer cmake and Cap'n Proto versions (#212, #359), CI coverage for the minimum supported g++ (#330, #366), new CI warnings (#332, #341), CI parallelism (#334, #356), CI diagnostics (#351, #352), Nix and LLVM updates (#296, #363), NetBSD and OpenBSD CI fixes (#321, #340, #381), building Cap'n Proto with GCC in the 32-bit CI job to avoid an ABI mismatch (#383), and GitHub Actions updates (#387).The second commit suppresses the clang
-Wc++23-lambda-attributeswarning, which the new[[noreturn]]lambda attribute inmp/proxy-types.htriggers in C++20 builds. Since #31507 the Windows build uses clang-cl, so the same flag covers it.The third commit updates the minimum Cap'n Proto version in
doc/dependencies.mdto 0.9.2 (1.0 with Clang). This update raises libmultiprocess's own minimum from 0.7 to 0.9 (bitcoin-core/libmultiprocess#331), and libmultiprocess rejects 0.9.0 and 0.9.1 for CVE-2022-46149 and, with Clang 16 or newer, every version before 1.0.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
-Wunusedby fanquake)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
could merge https://github.com/bitcoin/bitcoin/pull/31507 first and then rebase, to avoid a conflict and avoid having to add this line?
note to myself: Can be removed in https://github.com/bitcoin/bitcoin/pull/36036
9 additional verified findings in the full report.
🟠 Minor · Spawn's EOF handshake can wait for an unrelated notify process
A concurrent notify launch can inherit the error-report socket before FD_CLOEXEC is set, leaving an authenticated, IPC-backed echoipc call waiting for the unrelated process to exit.
Location:
src/ipc/libmultiprocess/src/mp/util.cpp:355(head).🟠 Minor · Error-channel allocation failure leaks the first socket pair
If the second SocketPair() fails under descriptor pressure, SpawnProcess leaks the two descriptors already allocated for IPC.
Location:
src/ipc/libmultiprocess/src/mp/util.cpp:257(head).🟠 Minor · Malformed -ipcchild values pass descriptor parsing
Bundled v14 accepts numeric prefixes such as "3abc" as descriptors instead of reporting the previous Invalid -ipcchild value error.
Location:
src/ipc/libmultiprocess/src/mp/util.cpp:345(head).🟠 Minor · Non-owning ConnectStream leaks its connection when construct() throws
A throwing construct() with destroy_connection=false leaves an unreachable Connection and its event-loop reference, preventing normal loop shutdown.
Location:
src/ipc/libmultiprocess/include/mp/proxy-io.h:879(head).🟠 Minor · The race regression test can finish its RPC before disconnecting
The new TSan regression test can fail on correct code if the main thread is delayed beyond the worker's fixed 200 ms sleep.
Location:
src/ipc/libmultiprocess/test/mp/test/test.cpp:441(head).🟠 Minor · Local dependency jobs reuse the first Cap'n Proto checkout
Successive local olddeps and newdeps runs share capnp/, so later runs can ignore the requested dependency revision even with CI_CLEAN=1.
Location:
src/ipc/libmultiprocess/ci/scripts/ci.sh:28(head).Review coverage was incomplete.
Reviewed:
d5f7524897dd· Full review report · Previous reportspermalink
There appears to be a race here (
FD_CLOEXECis not set atomically with socket creation). It is unlikely to be triggered during normal Core operation today, but the risk could increase ifSpawnProcess()is used more widely.#31507 has been merged. So could rebase here?
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased
13cf5d60ad->4898199d8f(pr/subtree-15.1->pr/subtree-15.2, compare) onto the latest master branches, adding bitcoin-core/libmultiprocess#365 and bitcoin-core/libmultiprocess#389 to the change list. Also drops the MSVC/wd5283line after #31507, since the Windows build now uses clang-cl.re: https://github.com/bitcoin/bitcoin/pull/36747#discussion_r4467127171
Thanks, rebased after #31507 and dropped the
/wd5283line, since the Windows build now uses clang-cl and the-Wno-c++23-lambda-attributesflag covers it.In commit "Merge commit '
270f5dbe3d' into pr/subtree-15" (c4ffd4e69f)Note for reviewers: This update includes bitcoin-core/libmultiprocess#365, which I merged without a current ACK, so post-merge review would be welcome here or on that PR. The only ACK was on an earlier push that differs by one IWYU comment.
re: https://github.com/bitcoin/bitcoin/pull/36747#discussion_r4466803696
Yes, this is a known race, noted in https://github.com/bitcoin-core/libmultiprocess/pull/311#pullrequestreview-4738358360 and https://github.com/bitcoin-core/libmultiprocess/pull/312#pullrequestreview-4818268394 as something follow-ups could improve. bitcoin-core/libmultiprocess#311 narrowed it, so now it only happens if an unrelated thread calls
fork()between thesocketpair()andfcntl()calls here. It is also not the only way descriptors can leak into child processes, since Bitcoin Core does not setFD_CLOEXECon most of its own descriptors. As I recall there wasn't a cross-platform way to create the socket pair withFD_CLOEXECset atomically, so the code sets the flag afterward to keep things simple.This code is in the libmultiprocess subtree, so a change would need to go upstream in https://github.com/bitcoin-core/libmultiprocess, and I'd be happy to review a PR there improving it.
utACK
4898199d8fDo we need to bump doc/dependencies.md to v0.9.2 here? (and would it be 1.0+ for clang)
Guix Build:
Added 1 commits
4898199d8f->d5f7524897(pr/subtree-15.2->pr/subtree-15.3, compare) adding a commit that updates the minimum Cap'n Proto version indoc/dependencies.md, as willcl-ark suggestedre: https://github.com/bitcoin/bitcoin/pull/36747#pullrequestreview-5783814463
In commit "doc: Bump minimum required Cap'n Proto version to 0.9.2" (
d5f7524897)Thanks, yes to both. This update raises libmultiprocess's minimum from 0.7 to 0.9 (bitcoin-core/libmultiprocess#331), and its CMakeLists.txt rejects 0.9.0 and 0.9.1 because of CVE-2022-46149, and rejects 0.9.x and 0.10.x when building with Clang 16 or newer in C++20 mode. With Bitcoin Core requiring Clang 17, that makes the Clang minimum 1.0, so I added a commit updating
doc/dependencies.mdto say 0.9.2 (1.0 with Clang).ACK
d5f7524897ACK
d5f7524897Checked the merge/integration more than the upstream changes themselves, although I did have an LLM whizz over them too. It surfaced one or two potential "upstream bugs", which we don't have a production use of, so I don't consider worthwhile mentioning here.
Tangential to this PR, but we could also drop libmultiprocess from the dependency table while keeping
WITH_EXTERNAL_LIBMULTIPROCESSdocumented in the IPC development instructions.Normal builds use the bundled revision by default anyway, and the external option seems mainly useful for libmultiprocess development. Listing a minimum external version there makes it look like a dependency users need to install (and whose compatible version numbers we need to keep updated).
Thanks for reviews and merge!
Now that this is merged, https://github.com/bitcoin-core/libmultiprocess/pull/388 should be merged before other libmultiprocess changes, and needs review for the
version.hchange (trivial).(https://github.com/bitcoin-core/libmultiprocess/pull/365 could use review as well since I merged it without an ack on the latest commit)
I don't think 0.9.2 is true for GCC either. It fails in G++13. See https://godbolt.org/z/z15x6d7bn , P2468R2 and https://github.com/bitcoin/bitcoin/pull/36033#discussion_r4694962976