Repository navigation
Conversation
This avoids a std::span ctor. Recommended in bitcoin-core#305 (review)
Recommended by the LLM in bitcoin/bitcoin#35684 (comment)
Factor out the write-message-then-_exit(126) pattern used when a syscall fails in the post-fork child of SpawnProcess, and document its constraints (async-signal-safe calls only, message must not allocate) in one place. The execvp failure path is intentionally left alone: replacing perror() there would lose the errno string, and improving it is already covered by the existing TODO about reporting errors to the parent via a pipe. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SpawnProcess cleared FD_CLOEXEC on the child's socket in the parent before forking. Between that fcntl() and fork(), a concurrent fork+exec on another thread would snapshot the descriptor with the close-on-exec flag already cleared, leaking it into an unrelated child process where it survives exec. A leaked duplicate of the socket also prevents the parent from seeing EOF when the spawned process exits. Instead, keep both descriptors close-on-exec in the parent for their entire lifetime and have the intended child clear the flag on its own copy of the descriptor between fork() and exec(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add `DefaultLogHandler` and a `log_handler` parameter so tests can provide their own handler and observe log output more easily.
Error seen (MSVC native build): mpgen error: mp\util.cpp:332: failed: CreateProcessA(...): bitcoin-core#2 The system cannot find the file specified. Problem: mpgen constructs capnp tool paths as capnp_PREFIX + "/bin/capnp" and capnp_PREFIX + "/bin/capnpc-c++". capnp_PREFIX is derived from the capnproto include directory parent, so on a vcpkg install it resolves to something like vcpkg_installed/x64-windows-release. But vcpkg installs executables under tools/capnproto/, not bin/, so the constructed path does not exist and CreateProcessA fails with ERROR_FILE_NOT_FOUND. Fix: pass the CAPNP_EXECUTABLE and CAPNPC_CXX_EXECUTABLE cmake variables from CapnProtoConfig.cmake as compile definitions to mpgen, and use them in gen.cpp instead of constructing paths from capnp_PREFIX. Using these cmake variables rather than reading the CapnProto::capnp_tool imported target IMPORTED_LOCATION directly is important: on Debian/Ubuntu, IMPORTED_LOCATION is set to a non-existent path due to a multiarch cmake packaging bug in libcapnp-dev (see bitcoin-core#328). The cmake variables avoid this because CapnProtoConfig.cmake hardcodes the correct paths on Debian/Ubuntu, and on other platforms (including vcpkg) the variables hold generator expressions that target_compile_definitions evaluates correctly at generation time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce CurrentThread() as an accessor for the existing namespace-scope thread_local object and migrate internal callers to it. This does not change storage duration, initialization, destruction, the exported TLS symbol, or its lint suppressions. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
bitcoin/bitcoin#35084 has now been merged.
…tThread(), ci: switch Bitcoin Core to master 66298c7 ci: Switch back to Bitcoin Core's master branch (Hennadii Stepanov) 86b4810 refactor: access ThreadContext through CurrentThread() (Sjors Provoost) Pull request description: This is a minimal subset from bitcoin-core#318 needed to match the shim introduced by bitcoin/bitcoin#35084. Should unblock bitcoin-core#322, see bitcoin-core#322 (comment). Include bitcoin-core#322 here, because CI will not pass now since bitcoin/bitcoin#35084 merged. ACKs for top commit: xyzconstant: ACK 66298c7 hebasto: ACK 66298c7. ViniciusCestarii: ACK 66298c7 ryanofsky: Code review ACK 66298c7. This nicely separates the `CurrentThread` refactoring from the mingw bug workaround. But it's misleading to call this a minimal fix for compatibility, because a minimal fix would just be: Tree-SHA512: 04cdb9f72c01279a7d9d8bd5735be5114dc6c37a5c66c5cab3e199d48c42da30d2db4c0bcd4f3bcf5508a04a52c78d63945b7ea9b605624353478872d38c5ebe
Since bitcoin-core#274, connection setup has been split into two calls: `MakeStream` followed by `ConnectStream`. Between these calls, the event loop's reference count can temporarily drop to zero, allowing `EventLoop::loop()` to exit before `ConnectStream` posts its work, crashing the example on startup. Keep an `EventLoopRef` alive in main() so the loop stays running while it is in use.
`EventLoop::loop()` exits when the last `EventLoopRef` is released, so code making multiple calls against the loop needs to hold its own reference. State this in the `EventLoopRef` comment and usage.md.
Connect to the listening socket and `close()` the connection right away, note that this is racy and the connection might be accepted normally if the `close()` syscall doesn't win the race. Additionally, a custom log handler is added to catch "Uncaught exception in daemonized task." logs, generated by a Cap'n Proto bug that shows up on macOS, so CI does not fail on them.
…parent before fork 1e0c7ff util: Clear FD_CLOEXEC in child instead of parent before fork (Sjors Provoost) 8550ee6 util, refactor: Add ChildFail helper for post-fork child errors (Sjors Provoost) Pull request description: Commit 652934f in bitcoin-core#274 _sets_ `FD_CLOEXEC` in order "to ensure sockets are not leaked if processes are spawned". However it's _cleared_ too early, before forking. This PR clears it _after_ forking, but still before exec. The first commit adds a helper for signal-safely emitting an error message, since the second commit also needs this. The second commit and a code comment explain why it's unsafe to clear `FD_CLOEXEC` before fork. ryanofsky also described it: > As I understand it, this race has always existed, and was not introduced in [652934f](bitcoin-core@652934f). What [652934f](bitcoin-core@652934f) did was start using `FD_CLOEXEC` which narrowed the race window, without completely closing it. This followup PR fixes the race more completely, but there is still a small race between creating the socketpair and applying the cause the CLOEXEC flags. > > The race happens when a `SpawnProcess` call happens at the same time as a separate `fork` call in unrelated thread not using `SpawnProcess`. Because `SpawnProcess` creates a socket pair, if a separate `fork` happens in another thread, it could inherit the socket pair file descriptors and keep them open too long if it is not looping over them and closing them like `SpawnProcess` is. As I understand it this could result in `socketpair` connections staying open even after the `SpawnProcess` parent or child have closed them, so `onDisconnect` events might not be triggered, and resources might not be freed. A test in 1e1ff03 demonstrates the issue, but is not included in the PR to keep things simple. This should not be an actual problem in the way Bitcoin Core uses libmultiprocess today, but it may be with Windows and/or multiple connection support. ACKs for top commit: ViniciusCestarii: ACK 1e0c7ff verified that without this change the test 1e1ff03 fails and that this really tightens the race window to just between socketpair and fcntl syscalls. ryanofsky: Code review ACK 1e0c7ff. Thanks for the fix! I think it's be good to add bugfix: to the title and make PR description describe bug more practically. xyzconstant: tACK 1e0c7ff Tree-SHA512: eaf127de19ad579dc2adc1276f7e160e9b6478257cadccfa7b4dd3faf348cb11b58394d1e7987e81a6fc0001410c73f923c0d7ce63c235f43d0c599226bffc13
36c6c63 doc: Document reference-counted EventLoop lifetime (xyzconstant) 3a997e1 Fix startup race in mpexample (xyzconstant) Pull request description: Since bitcoin-core#274, connection setup has been split into two calls: `MakeStream` followed by `ConnectStream`. Between these calls, the event loop's reference count can temporarily drop to zero, allowing `EventLoop::loop()` to exit (and the EventLoop to be destroyed) before `ConnectStream` posts its work. This crashes mpexample on startup. Fix this by keeping an `EventLoopRef` alive in main() so the loop stays running while it is in use. This same pattern is already used in Bitcoin Core (`m_loop_ref` member of `CapnpProtocol`). A second commit documents the reference-counted EventLoop lifetime in the `EventLoopRef` class comment and in `doc/usage.md`. NOTE: On macOS, mpexample was crashing intermittently on startup (sometimes failing the m_post_fn == nullptr assert in the EventLoop destructor, sometimes with a mutex lock failure), depending on timing. With this change, the crashes are gone. ACKs for top commit: ryanofsky: Code review ACK 36c6c63. Thanks for the fix, documentation, and simplification! Tree-SHA512: 69ed48484bb0c4889116fe98ed002cce2aeba65f6bfb1fd3d250aa34f7205669caa10990d6fac71cb4733a3b29a178e65be34fcd1dfb03b11de5a9fb956377da
Exclude bool from the integral BuildPrimitive overload (bool is integral per std::is_integral_v but not a standard integer per std::cmp_*); add a dedicated bool overload that static_asserts the capnp LocalType is also bool, so a schema mismatch (e.g. Float64 used for a bool parameter) produces a clear error pointing at the schema. This change is also needed so the next commit can tighten the integer range changes in the BuildPrimitive integer overload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use std::cmp_less_equal/std::cmp_greater_equal (C++20) in the range static_asserts to avoid signed/unsigned comparison pitfall: when one side is unsigned and the other signed, the usual arithmetic conversions silently convert the signed lowest() to a huge positive number, making the assert pass when it should fire. Also fix the identical pattern in type-number.h BuildPrimitive. Problem was reported by ViniciusCestarii in bitcoin-core#303 (comment) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…chrono::time_point Needed by bitcoin/bitcoin#34882 which uses NodeClock::time_point in the Node stats struct (m_last_send, m_last_recv, m_ping_start), requiring IPC serialization support for time_point types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…anges eea9c64 cmake: Fix stale codegen when mpgen binary changes (ViniciusCestarii) Pull request description: Add MPGEN_BINARY to DEPENDS so target_capnp_sources() also rebuilds when mpgen binary changes. This prevents stale code gen when mpgen binary changes but capnp files don't. I noticed this after seeing IWYU errors while building the examples, which were caused by stale generated code that no longer matched what the current mpgen produces. ACKs for top commit: xyzconstant: ACK eea9c64 hebasto: ACK eea9c64. ryanofsky: Code review ACK eea9c64. Nice fix which should make testing generator changes more convenient. Tree-SHA512: 9685a5c6a2ef9826be990216e7830833f3c1731808436d37a10dc26006674d5e50253236a341261ea4acfa9b997342e8ba255e7073a02eb4f2064e74d84dace0
I think there is no issue of passing a nullptr to memcpy here, but it makes sense to use the std-lib copy for consistency. Recommended in bitcoin-core#305 (review) Also, add a size sanity check when reading a char array.
Cap'n Proto's Autotools-installed package config forwards the `QUIET`
option to its internal `find_package(PkgConfig)` call and, when `QUIET`
is given, suppresses its own diagnostics. As a result, a missing
`PkgConfig` (for example, with the system `capnproto` package on NetBSD)
was indistinguishable from `capnproto` itself being absent.
Without `QUIET`, the actual cause can be diagnosed:
```
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
CMake Warning at /usr/pkg/lib/cmake/CapnProto/CapnProtoTargets.cmake:40 (message):
pkg-config cannot be found
Call Stack (most recent call first):
/usr/pkg/lib/cmake/CapnProto/CapnProtoConfig.cmake:102 (include)
CMakeLists.txt:16 (find_package)
CMake Warning at CMakeLists.txt:16 (find_package):
Found package configuration file:
/usr/pkg/lib/cmake/CapnProto/CapnProtoConfig.cmake
but it set CapnProto_FOUND to FALSE so package "CapnProto" is considered to
be NOT FOUND.
CMake Error at CMakeLists.txt:18 (message):
Cap'n Proto is required but was not found.
To resolve, choose one of the following:
- Install Cap'n Proto (version 1.0+ recommended)
- For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support
-- Configuring incomplete, errors occurred!
```
Instead, use only the required kj-async.
The removed code has been dead since db4f9a3, which bumped the minimum required Cap'n Proto version to 0.9.
NetBSD 9.x will become unsupported once release 11.0 is released.
Also document a workaround for a bug in Cap'n Proto affecting compilers prior to GCC 14.
fa30e20 ci: Remove hard-coded -j4 from sanitize config (marco) Pull request description: Not needed after CMAKE_BUILD_PARALLEL_LEVEL is set to nproc. ACKs for top commit: hebasto: ACK fa30e20. Tree-SHA512: 2643d3f29eea596765db4488d927a87493012e12d4f464879bdb7d8feb4bb39c281c711c3981fb3e44da7d77a575c40d199f2db9562cc97419bbdc1e43ffb7e7
81f824b doc: Update Cap'n Proto version to match minimum (Hennadii Stepanov) Pull request description: This was overlooked in bitcoin-core#331. ACKs for top commit: maflcko: lgtm ACK 81f824b Tree-SHA512: f1330b4a5797acc3e950d2ebb5eab012d86cd5647cfad158d5e08d6e8efb0838e642491840f0dddecf1f51ac380862cb792cc25f854f2c3204fba7d3e8bf67c3
fa10111 refactor: Enable readability-container-contains (marco) Pull request description: This is enabled downstream, so should be fine to enable here as well. ACKs for top commit: hebasto: ACK fa10111. Tree-SHA512: cecab3101322a56634c8c3fa23aef530fd041fa12597a4dfe613d823e67b99456da8003622d4ea349f38cba96fed2e50cbc178655374d3032e089f578d9601f0
kj::FunctionParam only stores a pointer to the caller's callable instead of taking ownership of it. This avoids a heap allocation per call, and is safe because EventLoop:sync() is synchronous, so the callable is guaranteed not to go out of scope before the event loop thread is done running it. It also means the callable does not need to be copyable or movable.
…() taking kj::FunctionParam 5c49666 refactor: rename EventLoop::m_post_fn to m_sync_fn (ViniciusCestarii) 2330fbe refactor: replace EventLoop::post() with sync() taking kj::FunctionParam (ViniciusCestarii) Pull request description: EventLoop::post() and the sync() wrapper around it did the same thing, so this merges them into a single sync() method. And also takes the callback as a [kj::FunctionParam](https://github.com/capnproto/capnproto/blob/v1.5.0/c%2B%2B/src/kj/function.h#L91) instead of a kj::Function: FunctionParam stores only a pointer to the caller's callable rather than taking ownership of it, so the callable no longer needs to be copyable or movable, and each call avoids a heap allocation. This is safe because sync() does not return until the event loop thread has finished running the callback and cleared m_post_fn(now named m_sync_fn), so the pointer is never used after the callable goes out of scope. ACKs for top commit: xyzconstant: re-ACK 5c49666 ryanofsky: Code review ACK 5c49666. Just moved since comment since last review Tree-SHA512: 563f4c549e7f75e0f736cfa209ed0c157bb9c069e31180f95fbc5d35f375db1658ce044d5649c243c6f839909fdeb767f302d8838f2c1218748f674367eb8910
… runs 7c73cce ci: rename CI-internal variables to use CI_ prefix (Ryan Ofsky) fe1b833 ci: do not ignore NIXPKGS_CHANNEL in local ci runs (Ryan Ofsky) Pull request description: Currently, the `olddeps` ci job specifies nixos-25.05 channel, but this is ignored in local ci runs, because the channel is set in `.github/workflows/ci.yml` not `ci/scripts/run.sh`. Fix this and also rename CI environment variables to consistently use `CI_` prefix ACKs for top commit: maflcko: review ACK 7c73cce 🌘 Tree-SHA512: 938ce48f2640d2715bf1b8dcca5b601c7fb213c2137437759f46a0a45e5782b1d8ccc282094aa947abafc2f7fda3c2cdbc32107c0f7e5c318224273caa21705c
766867f ci: clarify CAPNP_CHECKOUT=master is the v1.x release branch (Ryan Ofsky) cc36752 ci: bump cmake version to 4.3.4 in newdeps job (Ryan Ofsky) Pull request description: Update cmake from 4.1.1 to 4.3.4 and add capnproto branch comment as suggested in bitcoin-core#212 reviews ACKs for top commit: maflcko: lgtm ACK 766867f code changes seem fine, but the `Co-Authored-By: Claude` seems a bit extraneous, when all it did was cherry-picking my diff from GitHub. No strong opinion, but my preference would be to drop the tag here. hebasto: ACK 766867f. Tree-SHA512: 10a8643256703a2aeaed90448ae24254dab86b683fe44e34c93afdbe6e2de859274b1a0a30c73a3401f174066b1e01c614593cb4c6bb364aa5aa517066d22fcc
fa1db7a pull latest .clang-tidy from downstream (marco) Pull request description: Seems fine to do after bitcoin-core#358, given that it is passing CI ACKs for top commit: hebasto: ACK fa1db7a. Tree-SHA512: 61551f40d900471cade35afa719b4ff84f2a40e18d004b45bf7ff51d1bbac2da25d1ab2d356e88b3c18d0c52d9ea223f886e650b79d91ea6d26acd9e6022f538
a7ff9d5 ci: add cmake debug output (Ryan Ofsky) Pull request description: Show detailed debug information if cmake fails in CI ACKs for top commit: hebasto: re-ACK a7ff9d5. Tree-SHA512: 49e396abe6a87ce4500f7f582e1e20cfced41671986b4d04362e9005f3369745315cd3908dced8c7e9fc7b9cd8d2ba497658f871aed00f42d8dcb26994a3428b
fb4ac7e ci: use LLVM 23 in Bitcoin Core CI (fanquake) Pull request description: We recently switched a number of jobs downstream: bitcoin/bitcoin#36100. ACKs for top commit: hebasto: ACK fb4ac7e, Tree-SHA512: b55426bc618d875159281f5c4bdeee85514787761c92d51a02133ac63d76a3cc950d6b68cfeb878409246a9ed1c53b5d0464809c85c6d90afb6162346a839d1b
libmultiprocess requires capnp/kj to be built with exception support: mp::serverInvoke (proxy-types.h) relies on capnp's RPC layer catching exceptions thrown by server methods and converting them into remote-exception replies for the client, which capnp only does when KJ_NO_EXCEPTIONS is unset. If it's set, that conversion code (kj::getCaughtExceptionAsKj) is compiled out of capnp/kj, and an exception thrown by a server method escapes uncaught instead, crashing the process. This was hit in practice on NetBSD (bitcoin/bitcoin#36058): capnp's kj/common.h exception-support autodetection is fooled there, because NetBSD's <sys/cdefs.h> defines a dummy __has_feature(x)=0 stub for compilers (GCC<14) that don't natively support __has_feature. capnp reads that as "no exceptions" even though the compiler has exceptions enabled, so NetBSD's prebuilt capnproto package ends up linked without the exception-catching code libmultiprocess needs. Fixed upstream in capnproto/capnproto#2756, but not yet in any capnproto release or in NetBSD's pkgsrc package. Fail the build immediately with an explanatory #error instead of letting this surface later as a runtime crash on the affected platform. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
When building against static Cap'n Proto libraries, `mpgen` compilation fails at link time as `libcapnpc.a` depends on symbols defined in `libcapnp.a`. Flipping the order fixes the undefined references.
…PTIONS is set 4a1f400 util: Error out at compile time if KJ_NO_EXCEPTIONS is set (Ryan Ofsky) Pull request description: Cap'n Proto has a bug on netbsd where it incorrectly detects compiler does not support exceptions (reported and fixed in capnproto/capnproto#2756) causing exceptions thrown from bitcoin core IPC methods not be caught and leading to the CI failure reported bitcoin/bitcoin#36058. Failure can be worked around by adding `-DKJ_NO_EXCEPTIONS=0`` to the build configuration so add an error message to detect when it would happen and suggest this. ACKs for top commit: xyzconstant: LGTM. ACK 4a1f400 hebasto: ACK 4a1f400, I have reviewed the code and it looks OK. Tree-SHA512: 93100177248f52323752e930b46651df6dde27a263dd8912420d965a1fb658faf02fdae0551f4fdf79cf6baa21900f32e5507395b44e2fe2cd6e1a066feac377
…olddeps fa56334 ci: Compile with minimum supported g++-10 in olddeps (marco) Pull request description: Follow up to bitcoin-core#330 (comment) ACKs for top commit: ryanofsky: Code review ACK fa56334. Thanks for also building Cap'n Proto (not just libmultiprocess) with GCC 10. Tree-SHA512: b4fa5172c7b77791216d36d7a468c7f522883aa20988ed81473539ef048f07a4c84ac9d5ad4f6602f3bfbd7c11352008a867a932ef633627697a716e4d36fb30
Declare SocketError as an inline variable so the header does not define a separate internal-linkage copy in every translation unit that includes it. Bitcoin Core's build now enables -Wunused-const-variable (bitcoin/bitcoin#36275), which with GCC warns about unused const variables defined in headers and fails the build with -Werror in every file that includes mp/util.h without using SocketError. Bitcoin Core made the same change to its own SocketError definition in bitcoin/bitcoin#35852. This change was written with Claude Opus 5.5 (1M context).
Bitcoin Core builds the libmultiprocess subtree with -Wunused-const-variable (bitcoin/bitcoin#36275). With GCC this warns about unused const variables defined in headers, so a header-level constexpr that is not inline breaks the Bitcoin Core build. Enable it in the GCC-based CI configs to catch this here first. Clang's -Wunused-const-variable does not warn about variables defined in headers, so it is not added to the clang configs. This change was written with Claude Opus 5.5 (1M context).
…ndefined references in static builds 56cfdaa Change CapnProto library linkage for mpgen (mutatrum) Pull request description: When building against static Cap'n Proto libraries, `mpgen` compilation fails at link time as `libcapnpc.a` depends on symbols defined in `libcapnp.a`. Flipping the order fixes the undefined references. I ran into this issue when compiling Bitcoin Core with IPC enabled in a Ubuntu/Debian container to produce self-contained binaries that can be extracted to a host. ACKs for top commit: ryanofsky: Code review ACK 56cfdaa. Thanks for the fix and the clear reproduction steps! The cause is a bug in Cap'n Proto's autotools packaging (details in the inline comment). Tree-SHA512: cdefd8107f7d411d19b90f247b328259e730fee2671af46f9ed35afe6d26050d51e0ad6c1c11e149e642ae68da9e5ecaf1fcb1998f4c4a7dcf9652e1f1f89676
Check that KJ_NO_EXCEPTIONS is defined before testing its value. Bitcoin Core builds the libmultiprocess subtree with -Wundef, so the plain `#if KJ_NO_EXCEPTIONS` check added in bitcoin-core#364 fails the build with -Werror whenever the macro is not defined, which is the normal case. This change was written with Claude Opus 5.5 (1M context).
Bitcoin Core builds the libmultiprocess subtree with -Wundef, so a preprocessor check on an undefined macro breaks the Bitcoin Core build. Enable it in one GCC and one clang config to catch this here first. This change was written with Claude Opus 5.5 (1M context).
Stop the compiler warning flags in CXXFLAGS from turning clang warnings into errors in the IWYU pass. IWYU's clang frontend receives the same flags as the real compiler, so in the GCC CI jobs (-Werror -Wpedantic) every KJ_TEST reports "'__COUNTER__' is a C2y extension" and the GCC-only -Wtrailing-whitespace is an unknown option. Once a file has enough tests to reach clang's 20-error limit (test/mp/test/test.cpp currently has 16), clang gives up, IWYU exits 1 without analyzing the file, and the build fails with no diagnostics. Real IWYU findings are still reported with -w. This change was written with Claude Opus 5.5 (1M context).
Run include-what-you-use through a wrapper script that makes CMake print its output when it fails without suggesting includes. CMake only relays IWYU output containing "should add these lines:" or "should remove these lines:", so a clang error in the IWYU pass (like the too-many-errors abort fixed in the previous commit) failed the build with a bare "Error 1" and nothing to debug. This change was written with Claude Opus 5.5 (1M context).
f0a1475 cmake: Show include-what-you-use diagnostics when it fails (Ryan Ofsky) 92127a9 cmake: Pass -w to include-what-you-use (Ryan Ofsky) Pull request description: **Problem:** The IWYU check in the default CI job can fail with a bare `Error 1` and no diagnostics ([example](https://github.com/bitcoin-core/libmultiprocess/actions/runs/34642191878/job/103404374280)). IWYU's clang frontend receives the GCC job's warning flags, so with `-Werror -Wpedantic` every `KJ_TEST` reports `'__COUNTER__' is a C2y extension` and the GCC-only `-Wtrailing-whitespace` is an unknown option. A file with 19 or more `KJ_TEST`s reaches clang's error limit, clang gives up before IWYU checks anything, and CMake discards IWYU's output because it contains no include suggestions. `test/mp/test/test.cpp` has 16 tests now. bitcoin-core#335 adds three more and its default job fails this way, and master will hit it too once a few more tests are added. **Solution:** Pass `-w` to IWYU so compiler warning flags no longer affect it, and run it through a small wrapper script that makes CMake print IWYU's output whenever it fails without suggesting includes. The wrapper works around a CMake bug ([cmake#28020](https://gitlab.kitware.com/cmake/cmake/-/issues/28020); an upstream fix in [cmake!9210](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9210) was approved but never finished) and can be dropped once CMake fixes it. ACKs for top commit: xyzconstant: LGTM ACK f0a1475 hebasto: ACK f0a1475, I have reviewed the code and it looks OK. Tree-SHA512: 3174270ac5bb3ec01a224b4a41761728870643f34f03f1d5826d2460de55853b615a900ed47685aa47f94886754450b753b8bf7d90bac512268e6993cdfcbe1b
…ocess headers 3577d23 ci: Enable -Wundef in default and llvm jobs (Ryan Ofsky) debd429 proxy-types: Avoid -Wundef error when KJ_NO_EXCEPTIONS is not defined (Ryan Ofsky) a8c64c7 ci: Enable -Wunused-const-variable in GCC jobs (Ryan Ofsky) 701449c util: Make SocketError inline constexpr (Ryan Ofsky) Pull request description: **Problem:** Bumping the libmultiprocess subtree in Bitcoin Core to current master breaks the build with `-Werror`. GCC reports `SocketError` as an unused const variable in every file that includes `mp/util.h` without using it (`-Wunused-const-variable`, enabled by bitcoin/bitcoin#36275; [CI failure](https://github.com/bitcoin/bitcoin/actions/runs/36795124510/job/110156702275)), and the `#if KJ_NO_EXCEPTIONS` check added in bitcoin-core#364 fails `-Wundef` when the macro is not defined. **Solution:** Make `SocketError` an `inline constexpr` variable, the same change Bitcoin Core made to its own `SocketError` in bitcoin/bitcoin#35852, and check `defined(KJ_NO_EXCEPTIONS)` before testing its value. Also enable both warnings in CI here (`-Wunused-const-variable` in the GCC configs, `-Wundef` in default and llvm) so these problems are caught before a subtree update. Details are in the commit messages. ACKs for top commit: maflcko: lgtm ACK 3577d23 Sjors: ACK 3577d23 xyzconstant: ACK 3577d23 ViniciusCestarii: tACK 3577d23 hebasto: ACK 3577d23, I have reviewed the code and it looks OK. Tree-SHA512: 2f5497d6cb5f3fc15dd079b4640021ec09ea1ba289e8575bb13e17a4127ee82a080aa9514bc1584a96bbeb4118e3009dff9b2c18519394dea5fd041a219f65fc
In the gnu32 job, capnproto (libkj) is compiled with Clang while libmultiprocess is compiled with GCC, but they handle empty structs differently on i686. Clang omits them, while GCC reserves a stack slot for them. This causes a segfault in calls to functions like `kj::str(kj::Exception)`, which internally pass an empty `Stringifier` object. This commit fixes the issue by compiling capnproto with the same toolchain as libmultiprocess (GCC) when i686 is detected in shell.nix.
A non-libmultiprocess client can send requests after destroy(), causing a null m_impl pointer to be dereferenced and triggering a SIGSEGV. It can also call destroy() while another request on the same object is active, freeing m_impl while that request is using it. Track requests queued or executing on worker threads with m_active_calls. Reject destroy() while other requests are active, and reject any requests received after destruction. Fixes bitcoin-core#378
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.
Test whether building Cap'n Proto with GCC fixes the i686 ABI crash exposed by the new destroy-call regression test.
Combines bitcoin-core/libmultiprocess 382 (
0e96139da1c6b56fa8f73171bc982f5fd23d81da) and bitcoin-core/libmultiprocess#383 (04a0465d67a58040013c74dbb92e0f7a0572cc0e) on their shared master base (2e7812a5a1ea8fada26f74b06be62e195a3783a5). The existing CI workflows run unchanged.The key result is the
build • gnu32job runningmptest, including "Calling IPC method after destroy and destroy during a call". Both source PRs were fetched before combining them, and the merge had no conflicts.Validation at
eb74f36dbd10fdcd45364f52e5f7b4d832bcbedd:build • gnu32passed in both the push run and the PR run. Both logs show GCC 15.3.0 andmptestpassing with the combined destroy-call regression tests and toolchain fix.__COUNTER__/-Wc2y-extensionswarning issue, also present in upstream 383 alone and addressed separately by bitcoin-core/libmultiprocess 381.Keep this test PR open until upstream 383 is merged. Rebase it onto updates to that PR, preserving the destroy-call regression tests, and rerun CI after each update.