Skip to content

Commit 132621f

Browse files
committed
Squashed 'src/ipc/libmultiprocess/' changes from 1b8d4a6f1e..47d79db8a5
47d79db8a5 Merge bitcoin-core/libmultiprocess#201: bug: fix mptest hang, ProxyClient<Thread> deadlock in disconnect handler f15ae9c9b9 Merge bitcoin-core/libmultiprocess#211: Add .gitignore 4a269b21b8 bug: fix ProxyClient<Thread> deadlock if disconnected as IPC call is returning 85df96482c Use try_emplace in SetThread instead of threads.find ca9b380ea9 Use std::optional in ConnThreads to allow shortening locks 9b07991135 doc: describe ThreadContext struct and synchronization requirements d60db601ed proxy-io.h: add Waiter::m_mutex thread safety annotations 4e365b019a ci: Use -Wthread-safety not -Wthread-safety-analysis 15d7bafbb0 Add .gitignore fe1cd8c761 Merge bitcoin-core/libmultiprocess#208: ci: Test minimum cmake version in olddeps job b713a0b7bf Merge bitcoin-core/libmultiprocess#207: ci: output CMake version in CI script 0f580397c9 ci: Test minimum cmake version in olddeps job d603dcc0ee ci: output CMake version in CI script 13424cf2ec Merge bitcoin-core/libmultiprocess#205: cmake: check for Cap'n Proto / Clang / C++20 incompatibility 72dce11864 Merge bitcoin-core/libmultiprocess#200: event loop: add LogOptions struct and reduce the log size 85003409f9 eventloop: add `LogOptions` struct 657d80622f cmake: capnproto pkg missing helpful error d314057775 cmake: check for Cap'n Proto / Clang / C++20 incompatibility 878e84dc30 Merge bitcoin-core/libmultiprocess#203: cmake: search capnproto in package mode only 1a85da5873 Merge bitcoin-core/libmultiprocess#202: doc: correct the build instructions for the example df01873e1e Merge bitcoin-core/libmultiprocess#197: ci: Add freebsd and macos build 3bee07ab33 cmake: search capnproto in package mode only b6d3dc4419 doc: correct the build instructions for example fa1ac30000 ci: Add macos and freebsd task git-subtree-dir: src/ipc/libmultiprocess git-subtree-split: 47d79db8a5528097b408e18f7b0bae11a6702d26
1 parent ecd1876 commit 132621f

File tree

17 files changed

+319
-102
lines changed

17 files changed

+319
-102
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: vmactions/openbsd-vm@v1
1919
with:
2020
prepare: |
21-
pkg_add -v cmake ninja git python bash
21+
pkg_add -v cmake ninja git bash
2222
run: |
2323
git clone --depth=1 https://codeberg.org/OpenBSD/ports.git /usr/ports
2424
sync: 'rsync'
@@ -34,6 +34,45 @@ jobs:
3434
cd ${{ github.workspace }}
3535
CI_CONFIG="ci/configs/openbsd.bash" bash ci/scripts/ci.sh
3636
37+
build-freebsd:
38+
runs-on: ubuntu-latest
39+
name: build • freebsd
40+
defaults:
41+
run:
42+
shell: freebsd {0}
43+
steps:
44+
- uses: actions/checkout@v5
45+
46+
- name: Start FreeBSD VM
47+
uses: vmactions/freebsd-vm@v1
48+
with:
49+
prepare: |
50+
pkg install -y cmake ninja bash capnproto
51+
sync: 'rsync'
52+
copyback: false
53+
54+
- name: Run CI script
55+
run: |
56+
cd ${{ github.workspace }}
57+
CI_CONFIG="ci/configs/freebsd.bash" bash ci/scripts/ci.sh
58+
59+
build-macos:
60+
runs-on: macos-latest
61+
name: build • macos
62+
63+
steps:
64+
- uses: actions/checkout@v5
65+
66+
- name: Install dependencies
67+
env:
68+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
69+
run: |
70+
brew install --quiet ninja capnp
71+
72+
- name: Run CI script
73+
run: |
74+
CI_CONFIG="ci/configs/macos.bash" bash ci/scripts/ci.sh
75+
3776
build:
3877
runs-on: ubuntu-latest
3978

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CMake artifacts
2+
/*build*
3+
4+
# Git artifacts
5+
*.patch

CMakeLists.txt

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ endif()
1313
include("cmake/compat_find.cmake")
1414

1515
find_package(Threads REQUIRED)
16-
find_package(CapnProto 0.7 REQUIRED)
16+
find_package(CapnProto 0.7 QUIET NO_MODULE)
17+
if(NOT CapnProto_FOUND)
18+
message(FATAL_ERROR
19+
"Cap'n Proto is required but was not found.\n"
20+
"To resolve, choose one of the following:\n"
21+
" - Install Cap'n Proto (version 1.0+ recommended)\n"
22+
" - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n"
23+
)
24+
endif()
25+
26+
# Cap'n Proto compatibility checks
27+
set(CAPNPROTO_ISSUES "")
28+
set(CAPNPROTO_CVE_AFFECTED FALSE)
29+
set(CAPNPROTO_CLANG_INCOMPATIBLE FALSE)
1730

1831
# Check for list-of-pointers memory access bug from Nov 2022
1932
# https://nvd.nist.gov/vuln/detail/CVE-2022-46149
@@ -29,11 +42,43 @@ if(CapnProto_VERSION STREQUAL "0.7.0"
2942
OR CapnProto_VERSION STREQUAL "0.10.0"
3043
OR CapnProto_VERSION STREQUAL "0.10.1"
3144
OR CapnProto_VERSION STREQUAL "0.10.2")
45+
set(CAPNPROTO_CVE_AFFECTED TRUE)
46+
string(APPEND CAPNPROTO_ISSUES "- CVE-2022-46149 security vulnerability (details: https://github.com/advisories/GHSA-qqff-4vw4-f6hx)\n")
47+
endif()
48+
49+
# Check for Cap'n Proto / Clang / C++20 incompatibility
50+
# Cap'n Proto 0.9.x and 0.10.x are incompatible with Clang 16+ when using C++20
51+
# due to P2468R2 implementation. This was fixed in Cap'n Proto 1.0+.
52+
# See: https://github.com/bitcoin-core/libmultiprocess/issues/199
53+
if((CapnProto_VERSION VERSION_GREATER_EQUAL "0.9.0") AND
54+
(CapnProto_VERSION VERSION_LESS "1.0.0") AND
55+
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
56+
(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16") AND
57+
(CMAKE_CXX_STANDARD EQUAL 20))
58+
set(CAPNPROTO_CLANG_INCOMPATIBLE TRUE)
59+
string(APPEND CAPNPROTO_ISSUES "- Incompatible with Clang ${CMAKE_CXX_COMPILER_VERSION} when using C++20\n")
60+
endif()
61+
62+
if(CAPNPROTO_CVE_AFFECTED OR CAPNPROTO_CLANG_INCOMPATIBLE)
63+
set(RESOLUTION_OPTIONS "")
64+
65+
# Fixes both issues
66+
string(APPEND RESOLUTION_OPTIONS " - Upgrade to Cap'n Proto version 1.0 or newer (recommended)\n")
67+
68+
if(CAPNPROTO_CVE_AFFECTED AND NOT CAPNPROTO_CLANG_INCOMPATIBLE)
69+
string(APPEND RESOLUTION_OPTIONS " - Upgrade to a patched minor version (0.7.1, 0.8.1, 0.9.2, 0.10.3, or later)\n")
70+
elseif(CAPNPROTO_CLANG_INCOMPATIBLE AND NOT CAPNPROTO_CVE_AFFECTED)
71+
string(APPEND RESOLUTION_OPTIONS " - Use GCC instead of Clang\n")
72+
endif()
73+
74+
string(APPEND RESOLUTION_OPTIONS " - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n")
75+
3276
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-
")
77+
"The version of Cap'n Proto detected: ${CapnProto_VERSION} has known compatibility issues:\n"
78+
"${CAPNPROTO_ISSUES}"
79+
"To resolve, choose one of the following:\n"
80+
"${RESOLUTION_OPTIONS}"
81+
)
3782
endif()
3883

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

ci/configs/freebsd.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CI_DESC="CI config for FreeBSD"
2+
CI_DIR=build-freebsd
3+
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter"
4+
CMAKE_ARGS=(-G Ninja)
5+
BUILD_ARGS=(-k 0)

ci/configs/llvm.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CI_DESC="CI job using LLVM-based libraries and tools (clang, libc++, clang-tidy,
22
CI_DIR=build-llvm
33
NIX_ARGS=(--arg enableLibcxx true)
44
export CXX=clang++
5-
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wthread-safety-analysis -Wno-unused-parameter"
5+
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wthread-safety -Wno-unused-parameter"
66
CMAKE_ARGS=(
77
-G Ninja
88
-DMP_ENABLE_CLANG_TIDY=ON

ci/configs/macos.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CI_DESC="CI config for macOS"
2+
CI_DIR=build-macos
3+
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter"
4+
CMAKE_ARGS=(-G Ninja)
5+
BUILD_ARGS=(-k 0)

ci/configs/olddeps.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CI_DESC="CI job using old Cap'n Proto version"
1+
CI_DESC="CI job using old Cap'n Proto and cmake versions"
22
CI_DIR=build-olddeps
33
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds"
4-
NIX_ARGS=(--argstr capnprotoVersion "0.7.1")
4+
NIX_ARGS=(--argstr capnprotoVersion "0.7.1" --argstr cmakeVersion "3.12.4")
55
BUILD_ARGS=(-k)

ci/configs/sanitize.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CI_DESC="CI job running ThreadSanitizer"
22
CI_DIR=build-sanitize
33
export CXX=clang++
4-
export CXXFLAGS="-ggdb -Werror -Wall -Wextra -Wpedantic -Wthread-safety-analysis -Wno-unused-parameter -fsanitize=thread"
4+
export CXXFLAGS="-ggdb -Werror -Wall -Wextra -Wpedantic -Wthread-safety -Wno-unused-parameter -fsanitize=thread"
55
CMAKE_ARGS=()
66
BUILD_ARGS=(-k -j4)
77
BUILD_TARGETS=(mptest)

ci/scripts/ci.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ fi
1717

1818
[ -n "${CI_CLEAN-}" ] && rm -rf "${CI_DIR}"
1919

20-
cmake -B "$CI_DIR" "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}"
21-
cmake --build "$CI_DIR" -t "${BUILD_TARGETS[@]}" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}"
22-
ctest --test-dir "$CI_DIR" --output-on-failure
20+
cmake --version
21+
cmake_ver=$(cmake --version | awk '/version/{print $3; exit}')
22+
ver_ge() { [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; }
23+
24+
src_dir=$PWD
25+
mkdir -p "$CI_DIR"
26+
cd "$CI_DIR"
27+
cmake "$src_dir" "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}"
28+
if ver_ge "$cmake_ver" "3.15"; then
29+
cmake --build . -t "${BUILD_TARGETS[@]}" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}"
30+
else
31+
# Older versions of cmake can only build one target at a time with --target,
32+
# and do not support -t shortcut
33+
for t in "${BUILD_TARGETS[@]}"; do
34+
cmake --build . --target "$t" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}"
35+
done
36+
fi
37+
ctest --output-on-failure

doc/usage.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ A simple interface description can be found at [test/mp/test/foo.capnp](../test/
1919
A more complete example can be found in [example](../example/) and run with:
2020

2121
```sh
22-
make -C build example
23-
build/example/mpexample
22+
mkdir build
23+
cd build
24+
cmake ..
25+
make mpexamples
26+
example/mpexample
2427
```

0 commit comments

Comments
 (0)