Run msan in CI. Closes #66
CI / pre-commit (push) Successful in 2m5s
CI / release (arm64, , ubuntu-latest-arm64) (push) Successful in 2m20s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (push) Successful in 3m27s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (push) Successful in 3m20s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (push) Successful in 3m16s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (push) Successful in 3m21s
CI / release (amd64, -DMSAN_TOOLCHAIN_PATH=/opt/msan, ubuntu-latest-amd64) (push) Successful in 5m47s
CI / coverage (push) Successful in 3m54s
CI / pre-commit (push) Successful in 2m5s
CI / release (arm64, , ubuntu-latest-arm64) (push) Successful in 2m20s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (push) Successful in 3m27s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (push) Successful in 3m20s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (push) Successful in 3m16s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (push) Successful in 3m21s
CI / release (amd64, -DMSAN_TOOLCHAIN_PATH=/opt/msan, ubuntu-latest-amd64) (push) Successful in 5m47s
CI / coverage (push) Successful in 3m54s
This commit is contained in:
+10
-1
@@ -116,8 +116,10 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- runner: ubuntu-latest-amd64
|
- runner: ubuntu-latest-amd64
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
cmake_args: -DMSAN_TOOLCHAIN_PATH=/opt/msan
|
||||||
- runner: ubuntu-latest-arm64
|
- runner: ubuntu-latest-arm64
|
||||||
arch: arm64
|
arch: arm64
|
||||||
|
cmake_args: ""
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -158,11 +160,18 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
ccache-release-${{ matrix.arch }}-
|
ccache-release-${{ matrix.arch }}-
|
||||||
|
|
||||||
|
- name: Download MSan toolchain
|
||||||
|
if: matrix.arch == 'amd64'
|
||||||
|
run: |
|
||||||
|
curl -Ls "https://minio.weaselab.dev/public/x86_64/msan-toolchain-21.1.8.tar.zst" -o /tmp/msan-toolchain.tar.zst
|
||||||
|
sudo mkdir -p /opt/msan
|
||||||
|
sudo tar --zstd -xf /tmp/msan-toolchain.tar.zst -C /opt/msan
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
|
export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
|
||||||
rm -rf build
|
rm -rf build
|
||||||
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS=-DNVALGRIND
|
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS=-DNVALGRIND ${{ matrix.cmake_args }}
|
||||||
ninja -C build
|
ninja -C build
|
||||||
ccache -s
|
ccache -s
|
||||||
|
|
||||||
|
|||||||
+35
-1
@@ -103,6 +103,13 @@ option(USE_SIMD_FALLBACK
|
|||||||
|
|
||||||
option(DISABLE_TSAN "Disable TSAN" OFF)
|
option(DISABLE_TSAN "Disable TSAN" OFF)
|
||||||
|
|
||||||
|
set(MSAN_TOOLCHAIN_PATH
|
||||||
|
""
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Path to an MSan-instrumented libc++ toolchain. When set, an MSan fuzz_driver target is added. Must contain include/c++/v1 and lib. See build_msan_toolchain.sh to produce one."
|
||||||
|
)
|
||||||
|
|
||||||
# This is encouraged according to
|
# This is encouraged according to
|
||||||
# https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq
|
# https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/valgrind)
|
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/valgrind)
|
||||||
@@ -253,7 +260,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND BUILD_TESTING)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# whitebox tests
|
# whitebox tests asan+ubsan
|
||||||
add_executable(fuzz_driver ConflictSet.cpp FuzzTestDriver.cpp)
|
add_executable(fuzz_driver ConflictSet.cpp FuzzTestDriver.cpp)
|
||||||
target_compile_options(fuzz_driver PRIVATE ${TEST_FLAGS})
|
target_compile_options(fuzz_driver PRIVATE ${TEST_FLAGS})
|
||||||
if(NOT CMAKE_CROSSCOMPILING)
|
if(NOT CMAKE_CROSSCOMPILING)
|
||||||
@@ -268,6 +275,33 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND BUILD_TESTING)
|
|||||||
add_test(NAME conflict_set_fuzz_${hash} COMMAND fuzz_driver ${TEST})
|
add_test(NAME conflict_set_fuzz_${hash} COMMAND fuzz_driver ${TEST})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# whitebox tests msan
|
||||||
|
if(MSAN_TOOLCHAIN_PATH)
|
||||||
|
add_executable(fuzz_driver_msan ConflictSet.cpp FuzzTestDriver.cpp)
|
||||||
|
target_compile_options(fuzz_driver_msan PRIVATE ${TEST_FLAGS})
|
||||||
|
if(NOT CMAKE_CROSSCOMPILING)
|
||||||
|
target_compile_options(
|
||||||
|
fuzz_driver_msan
|
||||||
|
PRIVATE -fsanitize=memory -fsanitize-memory-track-origins=2
|
||||||
|
-stdlib=libc++ -I${MSAN_TOOLCHAIN_PATH}/include/c++/v1)
|
||||||
|
target_link_options(
|
||||||
|
fuzz_driver_msan
|
||||||
|
PRIVATE
|
||||||
|
-fsanitize=memory
|
||||||
|
-fsanitize-memory-track-origins=2
|
||||||
|
-stdlib=libc++
|
||||||
|
-L${MSAN_TOOLCHAIN_PATH}/lib
|
||||||
|
LINKER:-rpath,${MSAN_TOOLCHAIN_PATH}/lib)
|
||||||
|
endif()
|
||||||
|
target_compile_definitions(fuzz_driver_msan PRIVATE ENABLE_FUZZ)
|
||||||
|
target_include_directories(fuzz_driver_msan
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
foreach(TEST ${CORPUS_TESTS})
|
||||||
|
get_filename_component(hash ${TEST} NAME)
|
||||||
|
add_test(NAME conflict_set_msan_${hash} COMMAND fuzz_driver_msan ${TEST})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
# tsan tests
|
# tsan tests
|
||||||
if(NOT CMAKE_CROSSCOMPILING AND NOT DISABLE_TSAN)
|
if(NOT CMAKE_CROSSCOMPILING AND NOT DISABLE_TSAN)
|
||||||
add_executable(tsan_driver ConflictSet.cpp FuzzTestDriver.cpp)
|
add_executable(tsan_driver ConflictSet.cpp FuzzTestDriver.cpp)
|
||||||
|
|||||||
+2
-2
@@ -1332,8 +1332,8 @@ TaggedNodePointer getChildGeq(Node *self, int child) {
|
|||||||
|
|
||||||
TaggedNodePointer getFirstChild(Node0 *) { return nullptr; }
|
TaggedNodePointer getFirstChild(Node0 *) { return nullptr; }
|
||||||
TaggedNodePointer getFirstChild(Node3 *self) {
|
TaggedNodePointer getFirstChild(Node3 *self) {
|
||||||
// Improves scan performance
|
// Don't prefetch since self->children[1] might be uninitialized and msan
|
||||||
self->children[1].prefetch();
|
// doesn't like that
|
||||||
return self->children[0];
|
return self->children[0];
|
||||||
}
|
}
|
||||||
TaggedNodePointer getFirstChild(Node16 *self) {
|
TaggedNodePointer getFirstChild(Node16 *self) {
|
||||||
|
|||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
LLVM_VERSION="${LLVM_VERSION:-21}"
|
||||||
|
MSAN_PREFIX="${MSAN_PREFIX:-$PWD/msan}"
|
||||||
|
JOBS="${JOBS:-$(nproc)}"
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
rm -rf libcxx-msan
|
||||||
|
mkdir libcxx-msan
|
||||||
|
cd libcxx-msan
|
||||||
|
|
||||||
|
git clone --depth=1 "https://github.com/llvm/llvm-project.git" -b "release/${LLVM_VERSION}.x"
|
||||||
|
|
||||||
|
cmake -S llvm-project/runtimes -B build_msan \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_CXX_COMPILER="clang++-${LLVM_VERSION}" \
|
||||||
|
-DCMAKE_C_COMPILER="clang-${LLVM_VERSION}" \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="${MSAN_PREFIX}" \
|
||||||
|
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
|
||||||
|
-DLLVM_USE_SANITIZER=MemoryWithOrigins
|
||||||
|
|
||||||
|
cmake --build build_msan -j"${JOBS}"
|
||||||
|
cmake --install build_msan
|
||||||
|
|
||||||
|
cmake -S llvm-project/runtimes -B build_nomsan \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_CXX_COMPILER="clang++-${LLVM_VERSION}" \
|
||||||
|
-DCMAKE_C_COMPILER="clang-${LLVM_VERSION}" \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="${MSAN_PREFIX}" \
|
||||||
|
-DLLVM_ENABLE_RUNTIMES="libunwind"
|
||||||
|
|
||||||
|
cmake --build build_nomsan -j"${JOBS}"
|
||||||
|
cmake --install build_nomsan
|
||||||
|
|
||||||
|
VERSION="$(clang-"${LLVM_VERSION}" --version | head -n1 | sed -E 's/.*clang version ([0-9.]+).*/\1/')"
|
||||||
|
TARBALL="msan-toolchain-${VERSION}.tar.zst"
|
||||||
|
|
||||||
|
tar --zstd -cf "${TARBALL}" -C "${MSAN_PREFIX}" .
|
||||||
|
|
||||||
|
TARBALL_PATH="$(pwd)/${TARBALL}"
|
||||||
|
echo "Created: ${TARBALL_PATH}"
|
||||||
Reference in New Issue
Block a user