From 91139664ceab82a389203d1aa8b7f60c23b562be Mon Sep 17 00:00:00 2001 From: Jared Duffey Date: Tue, 6 Aug 2024 17:21:48 -0400 Subject: [PATCH] BUG: Fixed ASAN CI test discovery and leak detection (#1037) * Fixed issue with catch2 test discovery for asan CI * Catch2 runs the test executable in order to discover the tests but the executable couldn't find the clang asan library in the build step * Added leak suppressions file for LeakSanitizer * Ignore leaks detected in: * "/usr/bin" e.g. bash and python * "site-packages/" e.g. numpy * "pybind11.h" * Currently having an issue with leaking enum bindings * https://github.com/pybind/pybind11/issues/3865 Signed-off-by: Jared Duffey --- .github/workflows/asan.yml | 13 ++++++------- utilities/leak_suppressions.txt | 3 +++ 2 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 utilities/leak_suppressions.txt diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index cf95df0d3b..603395e324 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -8,6 +8,8 @@ jobs: build: env: VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' + CC: clang-14 + CXX: clang++-14 runs-on: ubuntu-22.04 steps: - name: Checkout @@ -44,17 +46,14 @@ jobs: setapikey "${{secrets.GITHUB_TOKEN}}" \ -source "https://nuget.pkg.github.com/BlueQuartzSoftware/index.json" - name: Configure - env: - CC: clang-14 - CXX: clang++-14 run: | cmake --preset ci-asan ${{github.workspace}} - name: Build run: | + export LD_LIBRARY_PATH=$($CXX -print-file-name=libclang_rt.asan-x86_64.so) cmake --build --preset ci-asan - name: Test run: | - export LD_PRELOAD=$(clang++-14 -print-file-name=libclang_rt.asan-x86_64.so) - ctest --preset ci-asan -E "PY" - export ASAN_OPTIONS=detect_leaks=0 - ctest --preset ci-asan -R "PY" + export LD_PRELOAD=$($CXX -print-file-name=libclang_rt.asan-x86_64.so) + export LSAN_OPTIONS=suppressions=${{github.workspace}}/utilites/leak_suppressions.txt + ctest --preset ci-asan diff --git a/utilities/leak_suppressions.txt b/utilities/leak_suppressions.txt new file mode 100644 index 0000000000..021271ca16 --- /dev/null +++ b/utilities/leak_suppressions.txt @@ -0,0 +1,3 @@ +leak:pybind11.h +leak:/usr/bin +leak:site-packages/