From 92f2b2c6f333f8f0ef7686e34d51a24a74dad49d Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 15 Apr 2026 10:42:51 -0400 Subject: Enable ASAN --- .github/workflows/cmake-multi-platform.yml | 22 ++++++++++++++-------- CMakeLists.txt | 4 ++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index e3f0ce7..57ac65d 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -60,14 +60,19 @@ jobs: libzip - name: Configure CMake - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DTESTS=ON - -DTESTS_VERBOSE=ON - -DTESTS_RT=ON - -DDEBUG_MESSAGES=ON + run: | + maybe_asan="" + if [[ "${RUNNER_OS}" == "Linux" ]]; then + maybe_asan="-DASAN=ON" + fi + cmake -B ${{ steps.strings.outputs.build-output-dir }} \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + ${maybe_asan} \ + -DTESTS=ON \ + -DTESTS_VERBOSE=ON \ + -DTESTS_RT=ON \ + -DDEBUG_MESSAGES=ON \ -S ${{ github.workspace }} - name: Build @@ -80,3 +85,4 @@ jobs: run: ctest --build-config ${{ matrix.build_type }} --output-on-failure --output-junit results.xml --test-output-size-passed 65536 --test-output-size-failed 65536 env: STASIS_SYSCONFDIR: ../../.. + ASAN_OPTIONS: "verify_asan_link_order=0 strict_string_checks=1 detect_stack_use_after_return=1 detect_leaks=1" diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e310b..fc403ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,9 +10,13 @@ find_package(CURL) option(ASAN "Address Analyzer" OFF) set(ASAN_OPTIONS "-fsanitize=address,null,undefined") +message(CHECK_START "Enable Address Analyzer (ASAN)") if (ASAN) + message(CHECK_PASS "Yes") add_compile_options(${ASAN_OPTIONS} -fno-omit-frame-pointer -g -O0) add_link_options(${ASAN_OPTIONS}) +else() + message(CHECK_FAIL "No") endif() pkg_check_modules(ZIP libzip) -- cgit