From 179f8b2182bb6c24d1f2aa43cf79e7c07c5c14a4 Mon Sep 17 00:00:00 2001 From: lani_karrot Date: Mon, 12 Oct 2026 21:14:29 +0900 Subject: [PATCH] ci: add UBSan --- .github/workflows/sanitize.yml | 25 ++++++++++++++++++++++--- CMakeLists.txt | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sanitize.yml b/.github/workflows/sanitize.yml index 3dfc127e..010119c1 100644 --- a/.github/workflows/sanitize.yml +++ b/.github/workflows/sanitize.yml @@ -11,9 +11,25 @@ env: jobs: build: - name: Address Sanitizer + name: ${{ matrix.config.name }} runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + config: + - { + name: "Address Sanitizer", + sanitize: "address", + cc: "gcc", cxx: "g++" + } + - { + name: "Undefined Behavior Sanitizer", + sanitize: "undefined,float-cast-overflow", + cc: "clang", cxx: "clang++" + } + env: + UBSAN_OPTIONS: print_stacktrace=1 + steps: - name: Checkout uses: actions/checkout@v4 @@ -21,7 +37,10 @@ jobs: submodules: true persist-credentials: false - name: Configure - run: cmake -B build -S . -DSANITIZE=address + env: + CC: ${{ matrix.config.cc }} + CXX: ${{ matrix.config.cxx }} + run: cmake -B build -S . -DSANITIZE=${{ matrix.config.sanitize }} - name: Build C++ unit tests run: cmake --build build --config Release - name: Run C++ tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 86fe1aaf..686d1c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ endif() option(SANITIZE "Run sanitization checks (g++/clang only)" OFF) if(SANITIZE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + add_compile_options(-fno-sanitize-recover=all) add_compile_options(-fsanitize=${SANITIZE}) add_link_options(-fsanitize=${SANITIZE}) endif()