From b5175ddf6a3f38486725be5e924ad35acabf8fa0 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Tue, 14 Jan 2025 17:02:17 +0100 Subject: [PATCH] Second attempt at asan build --- .github/workflows/asan.yml | 66 ++++++++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/asan.yml diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml new file mode 100644 index 000000000..e258277b7 --- /dev/null +++ b/.github/workflows/asan.yml @@ -0,0 +1,66 @@ +name: Address sanitizer build + +on: + push: + branches: + - main + - dev + - alpha-dev + pull_request: + branches: + - main + - dev + - alpha-dev + workflow_dispatch: + +jobs: + address-sanitizer: + name: Address Sanitizer + runs-on: ubuntu-latest + env: + ASAN_OPTIONS: "alloc_dealloc_mismatch=0:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1" + + defaults: + run: + # Conda requires a login shell in order to work properly + shell: bash -l {0} + + steps: + - uses: actions/checkout@v4 + + - name: Create Helios dev environment + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + auto-activate-base: false + activate-environment: helios-dev + environment-file: environment-dev.yml + python-version: "3.12" + + - name: Install conda-based gcc + run: | + conda install -c conda-forge gcc gxx + + - name: Install Helios + run: | + python -m pip install \ + --no-build-isolation \ + --config-settings=build-dir="build" \ + --config-settings=cmake.build-type="Debug" \ + --config-settings=cmake.define.CMAKE_CXX_FLAGS="-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer" \ + --verbose \ + --editable \ + . + + - name: run python tests + # for LD_PRELOAD see https://github.com/google/sanitizers/issues/934#issuecomment-649516500 + run: | + echo "leak:/usr/bin/bash" > supp.txt + # hack to prevent external libs from dlclosing libraries, + # which otherwise results in LSAN leaks that cannot be suppressed + # https://github.com/google/sanitizers/issues/89#issuecomment-406316683 + echo "#include " > dlclose.c + echo "int dlclose(void *handle) { return 0; }" >> dlclose.c + clang -shared dlclose.c -o libdlclose.so + LSAN_OPTIONS=suppressions="$(pwd)/supp.txt" LD_PRELOAD="$(gcc -print-file-name=libasan.so) $(gcc -print-file-name=libstdc++.so) $(pwd)/libdlclose.so" PYTHONMALLOC=malloc helios --test + LSAN_OPTIONS=suppressions="$(pwd)/supp.txt" LD_PRELOAD="$(gcc -print-file-name=libasan.so) $(gcc -print-file-name=libstdc++.so) $(pwd)/libdlclose.so" PYTHONMALLOC=malloc python -m pytest -s diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c93f006be..5d79b96ba 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -40,7 +40,7 @@ jobs: - name: Install Conda GCC run: | - conda install -y -c conda-forge gcc gxx + conda install -c conda-forge gcc gxx - name: Install LCov run: |