From c0da8cdb0ae3371e5f3e240bfe31b602d09c0323 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Fri, 26 Jul 2024 14:01:09 +0200 Subject: [PATCH 1/3] Run tests with leak, undefined, and thread sanitizer in CI --- .github/workflows/build_and_test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 60f69e7..d6f0b85 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: buildtype: [debug, release] + sanitizer: [none, leak, undefined, thread] runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -21,13 +22,14 @@ jobs: - name: Set up ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: ccache-linux-${{ matrix.buildtype }} + key: ccache-linux-${{ matrix.buildtype }}-${{ matrix.sanitizer }} - name: Setup compiler and build tools run: sudo apt install --no-install-recommends --yes g++-12 meson ninja-build - name: Configure run: | CXX="ccache g++-12" meson setup \ --buildtype ${{ matrix.buildtype }} \ + -Db_sanitize=${{ matrix.sanitizer }} \ --warnlevel 3 \ --werror \ build . From 29617262bce0c844d8c196f5363ef9a52b98052f Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Fri, 6 Sep 2024 11:35:38 +0200 Subject: [PATCH 2/3] Run tests with address sanitizer in debug mode --- .github/workflows/build_and_test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index d6f0b85..777e68d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11,7 +11,11 @@ jobs: strategy: matrix: buildtype: [debug, release] - sanitizer: [none, leak, undefined, thread] + sanitizer: [none, address, leak, undefined, thread] + exclude: + # False positive warnings in release builds: https://godbolt.org/z/vT3nqGxzW + - buildtype: release + sanitizer: address runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 From 316f1c5e93e0acafbfa61b26b8b28e99d288f82c Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Fri, 6 Sep 2024 11:40:56 +0200 Subject: [PATCH 3/3] Enable stricter address sanitizer checks and be more verbose on errors --- .github/workflows/build_and_test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 777e68d..2015dfd 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -42,4 +42,7 @@ jobs: - name: Setup Test run: cd test/setup && ./setup - name: Test - run: cd build && ./unit + run: | + export ASAN_OPTIONS=fast_unwind_on_malloc=0:strict_string_checks=1:detect_leaks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 + export UBSAN_OPTIONS=print_stacktrace=1 + cd build && ./unit