Skip to content

Commit

Permalink
Add ASAN/UBSAN recipe to just, make a CI that runs it + adding GDB (#…
Browse files Browse the repository at this point in the history
…1474)

* Add ASAN/UBSAN recipe to just, make a CI that runs it
* Add GDB options to justfile
Module operandi I propose: we dont save the log for now, we dont run the leak sanitizer part, then we run this every time a new PR comes in, and if any of those introduce a problem, this test will fail. It will not show what the issue is (given the ASAN output saving problem), but it will show that there is an issue, so we can check out the branch locally and run this and we'll see the problem.
  • Loading branch information
tvami authored Sep 27, 2024
1 parent bde5418 commit 8efa112
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 5 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/asan_ubsan_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

name: Build with ASAN and UBSAN

on:
workflow_dispatch:
pull_request:
branches: [trunk]
types: [opened, ready_for_review]

env:
LDMX_DOCKER_TAG: ldmx/dev:latest

jobs:
build-with-asan-ubsan:
runs-on: ubuntu-latest
steps:
- name: Checkout ldmx-sw
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0

- name: Install just
uses: extractions/setup-just@v2
with:
just-version: 1.26.0

- name: Compile and Install ldmx-sw
run: |
just install-denv init configure-asan-ubsan
just build
shell: bash

- name: Run ecal_pn config
#continue-on-error: true
run: |
just setenv LDMX_NUM_EVENTS=15
just setenv LDMX_RUN_NUMBER=7500
#just setenv ASAN_OPTIONS=log_path=output.log
just setenv ASAN_OPTIONS=detect_leaks=0
just fire ${GITHUB_WORKSPACE}/.github/validation_samples/ecal_pn/config.py
shell: bash

# For the future, we could try to save the output of ASAN/UBSAN
# - name: Upload log artifact
# uses: actions/upload-artifact@v4
# with:
# name: ASAN_UBSAN_output
# path: output.log*
27 changes: 22 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,28 @@ install-denv:

# configure how ldmx-sw will be built
# added ADDITIONAL_WARNINGS and CLANG_TIDY to help improve code quality
configure *CONFIG:
denv cmake -B build -S . -DADDITIONAL_WARNINGS=ON -DENABLE_CLANG_TIDY=ON {{ CONFIG }}
# base configure command defining how cmake is called, private so only experts call it
[private]
configure-base *CONFIG:
denv cmake -B build -S . {{ CONFIG }}

# default configure of build when developing
configure *CONFIG: (configure-base "-DADDITIONAL_WARNINGS=ON -DENABLE_CLANG_TIDY=ON" CONFIG)

# configure minimal option for faster compilation
configure-quick: (configure-base)

# configure with Address Sanitizer (ASAN) and UndefinedBehaviorSanitizer (UBSan)
configure-asan-ubsan: (configure-base "-DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_SANITIZER_ADDRESS=ON")

# This is the same as just configure but reports all (non-3rd-party) warnings as errors
configure-force-error *CONFIG: (configure "-DWARNINGS_AS_ERRORS=ON" CONFIG)
configure-force-error: (configure "-DWARNINGS_AS_ERRORS=ON")

# This is an alternative compiler (clang) together with enabling the LTO sanitizer
# This is very helpful but for now it optimizes away our module linking, use for testing only
# Use alternative compiler and enable LTO (test compiling only, won't run properly)
configure-clang-lto: (configure "-DENABLE_LTO=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang")

# Keep debug symbols so running with gdb provides more helpful detail
configure-gdb: (configure-base "-DCMAKE_BUILD_TYPE=Debug")
# compile and install ldmx-sw
build ncpu=num_cpus():
denv cmake --build build --target install -- -j{{ ncpu }}
Expand All @@ -82,6 +94,11 @@ test *ARGS:
fire config_py *ARGS:
denv fire {{ config_py }} {{ ARGS }}

# run gdb on a config file
[no-cd]
debug config_py *ARGS:
denv gdb fire {{ config_py }} {{ ARGS }}

# initialize a containerized development environment
init:
#!/usr/bin/env sh
Expand Down

0 comments on commit 8efa112

Please sign in to comment.