Skip to content

Commit 6ca6f3b

Browse files
committed
Merge bitcoin/bitcoin#33241: Update libmultiprocess subtree to fix build issues
dd68d0f Squashed 'src/ipc/libmultiprocess/' changes from b4120d34bad2..1b8d4a6f1e54 (Ryan Ofsky) Pull request description: Includes: - bitcoin-core/libmultiprocess#193 - bitcoin-core/libmultiprocess#195 - bitcoin-core/libmultiprocess#194 These changes are needed to build fix libmultiprocess build issue that happens on OpenBSD and work around an incompatibility between GCC versions <14 and cap'nproto versions <0.9 when compiling with c++20 that was fixed upstream in capnproto/capnproto#1170. The issues were reported: - bitcoin/bitcoin#33219 - bitcoin/bitcoin#33176 - willcl-ark/bitcoin-core-docker#43 The fixes added CI jobs upstream to catch these issues earlier. The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh) ACKs for top commit: Sjors: ACK 323b3fd achow101: ACK 323b3fd hebasto: ACK 323b3fd, I've reproduced the subtree update locally. The two issues noted in this PR are unrelated to its changes and can be addressed separately. Tree-SHA512: 3d03693d269c04d9ed10e8dd03e8059062929f37616d974c6fdf346ee62737c990ec550e013575e7474bfa4efcead3938bf9b259d62c073d76e720ebafe4ff66
2 parents 9703b7e + 323b3fd commit 6ca6f3b

File tree

11 files changed

+128
-11
lines changed

11 files changed

+128
-11
lines changed

src/ipc/libmultiprocess/.github/workflows/ci.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,47 @@ on:
55
pull_request:
66

77
jobs:
8+
build-openbsd:
9+
runs-on: ubuntu-latest
10+
name: build • openbsd
11+
defaults:
12+
run:
13+
shell: openbsd {0}
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- name: Start OpenBSD VM
18+
uses: vmactions/openbsd-vm@v1
19+
with:
20+
prepare: |
21+
pkg_add -v cmake ninja git python bash
22+
run: |
23+
git clone --depth=1 https://codeberg.org/OpenBSD/ports.git /usr/ports
24+
sync: 'rsync'
25+
copyback: false
26+
27+
- name: Install capnproto
28+
run: |
29+
cd /usr/ports/devel/capnproto/
30+
make install
31+
32+
- name: Run CI script
33+
run: |
34+
cd ${{ github.workspace }}
35+
CI_CONFIG="ci/configs/openbsd.bash" bash ci/scripts/ci.sh
36+
837
build:
938
runs-on: ubuntu-latest
1039

1140
strategy:
1241
fail-fast: false
1342
matrix:
14-
config: [default, llvm, gnu32, sanitize]
43+
config: [default, llvm, gnu32, sanitize, olddeps]
1544

1645
name: build • ${{ matrix.config }}
1746

1847
steps:
19-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v5
2049

2150
- name: Install Nix
2251
uses: cachix/install-nix-action@v31 # 2025-05-27, from https://github.com/cachix/install-nix-action/tags

src/ipc/libmultiprocess/CMakeLists.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,29 @@ endif()
1212

1313
include("cmake/compat_find.cmake")
1414

15-
find_package(CapnProto REQUIRED)
1615
find_package(Threads REQUIRED)
16+
find_package(CapnProto 0.7 REQUIRED)
17+
18+
# Check for list-of-pointers memory access bug from Nov 2022
19+
# https://nvd.nist.gov/vuln/detail/CVE-2022-46149
20+
# https://github.com/advisories/GHSA-qqff-4vw4-f6hx
21+
# https://github.com/capnproto/capnproto/security/advisories/GHSA-qqff-4vw4-f6hx
22+
# https://github.com/capnproto/capnproto/blob/master/security-advisories/2022-11-30-0-pointer-list-bounds.md
23+
# https://capnproto.org/news/2022-11-30-CVE-2022-46149-security-advisory.html
24+
# https://dwrensha.github.io/capnproto-rust/2022/11/30/out_of_bounds_memory_access_bug.html
25+
if(CapnProto_VERSION STREQUAL "0.7.0"
26+
OR CapnProto_VERSION STREQUAL "0.8.0"
27+
OR CapnProto_VERSION STREQUAL "0.9.0"
28+
OR CapnProto_VERSION STREQUAL "0.9.1"
29+
OR CapnProto_VERSION STREQUAL "0.10.0"
30+
OR CapnProto_VERSION STREQUAL "0.10.1"
31+
OR CapnProto_VERSION STREQUAL "0.10.2")
32+
message(FATAL_ERROR
33+
"Cap'n Proto ${CapnProto_VERSION} is affected by CVE-2022-46149.\n"
34+
"Please install an updated package.\n"
35+
"Details: https://github.com/advisories/GHSA-qqff-4vw4-f6hx
36+
")
37+
endif()
1738

1839
set(MPGEN_EXECUTABLE "" CACHE FILEPATH "If specified, should be full path to an external mpgen binary to use rather than the one built internally.")
1940

src/ipc/libmultiprocess/ci/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CI_CONFIG=ci/configs/default.bash ci/scripts/run.sh
2020
CI_CONFIG=ci/configs/llvm.bash ci/scripts/run.sh
2121
CI_CONFIG=ci/configs/gnu32.bash ci/scripts/run.sh
2222
CI_CONFIG=ci/configs/sanitize.bash ci/scripts/run.sh
23+
CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
2324
```
2425

2526
By default CI jobs will reuse their build directories. `CI_CLEAN=1` can be specified to delete them before running instead.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CI_DESC="CI job using old Cap'n Proto version"
2+
CI_DIR=build-olddeps
3+
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds"
4+
NIX_ARGS=(--argstr capnprotoVersion "0.7.1")
5+
BUILD_ARGS=(-k)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CI_DESC="CI config for OpenBSD"
2+
CI_DIR=build-openbsd
3+
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter"
4+
CMAKE_ARGS=(-G Ninja)
5+
BUILD_ARGS=(-k 0)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
commit e3da7da967b94f373c29a198ce45f30fb9f0e517
2+
Author: Ed Catmur <[email protected]>
3+
Date: Tue Jan 31 16:27:04 2023 +0000
4+
5+
Remove operator!= synthesized by spaceship
6+
7+
An operator!= suppresses the reversed equality comparison candidate generation.
8+
9+
This is visible in clang 16 (rc0 just released) and in gcc trunk (so probably gcc 13).
10+
11+
diff --git a/c++/src/kj/string.h b/c++/src/kj/string.h
12+
index 193442aa..17835892 100644
13+
--- a/c++/src/kj/string.h
14+
+++ b/c++/src/kj/string.h
15+
@@ -122,10 +122,14 @@ public:
16+
inline constexpr const char* end() const { return content.end() - 1; }
17+
18+
inline constexpr bool operator==(decltype(nullptr)) const { return content.size() <= 1; }
19+
+#if !__cpp_impl_three_way_comparison
20+
inline constexpr bool operator!=(decltype(nullptr)) const { return content.size() > 1; }
21+
+#endif
22+
23+
inline bool operator==(const StringPtr& other) const;
24+
+#if !__cpp_impl_three_way_comparison
25+
inline bool operator!=(const StringPtr& other) const { return !(*this == other); }
26+
+#endif
27+
inline bool operator< (const StringPtr& other) const;
28+
inline bool operator> (const StringPtr& other) const { return other < *this; }
29+
inline bool operator<=(const StringPtr& other) const { return !(other < *this); }

src/ipc/libmultiprocess/doc/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# libmultiprocess Installation
22

3-
Installation currently requires Cap'n Proto:
3+
Installation currently requires Cap'n Proto 0.7 or higher:
44

55
```sh
66
apt install libcapnp-dev capnproto

src/ipc/libmultiprocess/example/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ add_executable(mpexample
2424
target_capnp_sources(mpexample ${CMAKE_CURRENT_SOURCE_DIR} init.capnp calculator.capnp printer.capnp)
2525
target_include_directories(mpexample PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
2626
target_link_libraries(mpexample PRIVATE Threads::Threads)
27-
target_link_libraries(mpexample PRIVATE stdc++fs)
2827

2928
add_custom_target(mpexamples DEPENDS mpexample mpcalculator mpprinter)

src/ipc/libmultiprocess/shell.nix

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,39 @@
22
, crossPkgs ? import <nixpkgs> {}
33
, enableLibcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++
44
, minimal ? false # Whether to create minimal shell without extra tools (faster when cross compiling)
5+
, capnprotoVersion ? null
56
}:
67

78
let
89
lib = pkgs.lib;
910
llvm = crossPkgs.llvmPackages_20;
10-
capnproto = crossPkgs.capnproto.override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; });
11+
capnprotoHashes = {
12+
"0.7.0" = "sha256-Y/7dUOQPDHjniuKNRw3j8dG1NI9f/aRWpf8V0WzV9k8=";
13+
"0.7.1" = "sha256-3cBpVmpvCXyqPUXDp12vCFCk32ZXWpkdOliNH37UwWE=";
14+
"0.8.0" = "sha256-rfiqN83begjJ9eYjtr21/tk1GJBjmeVfa3C3dZBJ93w=";
15+
"0.8.1" = "sha256-OZqNVYdyszro5rIe+w6YN00g6y8U/1b8dKYc214q/2o=";
16+
"0.9.0" = "sha256-yhbDcWUe6jp5PbIXzn5EoKabXiWN8lnS08hyfxUgEQ0=";
17+
"0.9.2" = "sha256-BspWOPZcP5nCTvmsDE62Zutox+aY5pw42d6hpH3v4cM=";
18+
"0.10.0" = "sha256-++F4l54OMTDnJ+FO3kV/Y/VLobKVRk461dopanuU3IQ=";
19+
"0.10.4" = "sha256-45sxnVyyYIw9i3sbFZ1naBMoUzkpP21WarzR5crg4X8=";
20+
"1.0.0" = "sha256-NLTFJdeOzqhk4ATvkc17Sh6g/junzqYBBEoXYGH/czo=";
21+
"1.0.2" = "sha256-LVdkqVBTeh8JZ1McdVNtRcnFVwEJRNjt0JV2l7RkuO8=";
22+
"1.1.0" = "sha256-gxkko7LFyJNlxpTS+CWOd/p9x/778/kNIXfpDGiKM2A=";
23+
"1.2.0" = "sha256-aDcn4bLZGq8915/NPPQsN5Jv8FRWd8cAspkG3078psc=";
24+
};
25+
capnprotoBase = if capnprotoVersion == null then crossPkgs.capnproto else crossPkgs.capnproto.overrideAttrs (old: {
26+
version = capnprotoVersion;
27+
src = crossPkgs.fetchFromGitHub {
28+
owner = "capnproto";
29+
repo = "capnproto";
30+
rev = "v${capnprotoVersion}";
31+
hash = lib.attrByPath [capnprotoVersion] "" capnprotoHashes;
32+
};
33+
patches = lib.optionals (lib.versionAtLeast capnprotoVersion "0.9.0" && lib.versionOlder capnprotoVersion "0.10.4") [ ./ci/patches/spaceship.patch ];
34+
} // (lib.optionalAttrs (lib.versionOlder capnprotoVersion "0.10") {
35+
env = { }; # Drop -std=c++20 flag forced by nixpkgs
36+
}));
37+
capnproto = capnprotoBase.override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; });
1138
clang = if enableLibcxx then llvm.libcxxClang else llvm.clang;
1239
clang-tools = llvm.clang-tools.override { inherit enableLibcxx; };
1340
in crossPkgs.mkShell {

src/ipc/libmultiprocess/src/mp/gen.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static void Generate(kj::StringPtr src_prefix,
146146
const std::vector<kj::Own<const kj::ReadableDirectory>>& import_dirs)
147147
{
148148
std::string output_path;
149-
if (src_prefix == ".") {
149+
if (src_prefix == kj::StringPtr{"."}) {
150150
output_path = src_file;
151151
} else if (!src_file.startsWith(src_prefix) || src_file.size() <= src_prefix.size() ||
152152
src_file[src_prefix.size()] != '/') {
@@ -156,7 +156,7 @@ static void Generate(kj::StringPtr src_prefix,
156156
}
157157

158158
std::string include_path;
159-
if (include_prefix == ".") {
159+
if (include_prefix == kj::StringPtr{"."}) {
160160
include_path = src_file;
161161
} else if (!src_file.startsWith(include_prefix) || src_file.size() <= include_prefix.size() ||
162162
src_file[include_prefix.size()] != '/') {
@@ -425,8 +425,8 @@ static void Generate(kj::StringPtr src_prefix,
425425

426426
const std::string method_prefix = Format() << message_namespace << "::" << method_interface.getShortDisplayName()
427427
<< "::" << Cap(method_name);
428-
const bool is_construct = method_name == "construct";
429-
const bool is_destroy = method_name == "destroy";
428+
const bool is_construct = method_name == kj::StringPtr{"construct"};
429+
const bool is_destroy = method_name == kj::StringPtr{"destroy"};
430430

431431
struct Field
432432
{
@@ -465,7 +465,7 @@ static void Generate(kj::StringPtr src_prefix,
465465
field.result_is_set = true;
466466
}
467467

468-
if (!param && field_name == "result") {
468+
if (!param && field_name == kj::StringPtr{"result"}) {
469469
field.retval = true;
470470
has_result = true;
471471
}

0 commit comments

Comments
 (0)