-
Notifications
You must be signed in to change notification settings - Fork 336
ci: add sanitizer workflows #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: sanitizers | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: read-all | ||
|
|
||
| env: | ||
| GOOGLETEST_VERSION: "1.15.2" | ||
|
|
||
| jobs: | ||
| sanitize: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 45 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - name: asan | ||
| sanitizer: address | ||
| compile_flags: "-fsanitize=address -fno-omit-frame-pointer" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not quoted correctly when expanded: https://github.com/google/s2geometry/actions/runs/18301785002/job/53309264384?pr=461#step:3:143 |
||
| link_flags: "-fsanitize=address -fno-omit-frame-pointer" | ||
| extra_packages: "" | ||
| - name: msan | ||
| sanitizer: memory | ||
| compile_flags: "-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -stdlib=libc++" | ||
| link_flags: "-fsanitize=memory -fsanitize-memory-track-origins -stdlib=libc++" | ||
| extra_packages: "libc++-dev libc++abi-dev libunwind-dev" | ||
| - name: tsan | ||
| sanitizer: thread | ||
| compile_flags: "-fsanitize=thread -fno-omit-frame-pointer" | ||
| link_flags: "-fsanitize=thread -fno-omit-frame-pointer" | ||
| extra_packages: "" | ||
| env: | ||
| CC: clang | ||
| CXX: clang++ | ||
| steps: | ||
| - name: Install additional packages | ||
| if: ${{ matrix.extra_packages != '' }} | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ${{ matrix.extra_packages }} | ||
|
|
||
| - uses: zacharyburnett/setup-abseil-cpp@713a4383f10b05948a6d9d4906056063c8da1168 # Not a release, but has #423 fix. | ||
| env: | ||
| CC: clang | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these need to be set again? I'm not very familiar with github actions. |
||
| CXX: clang++ | ||
| with: | ||
| cmake-build-args: >- | ||
| -DCMAKE_BUILD_TYPE=RelWithDebInfo | ||
| -DCMAKE_CXX_STANDARD=17 | ||
| -DABSL_PROPAGATE_CXX_STD=ON | ||
| -DABSL_ENABLE_INSTALL=ON | ||
| -DBUILD_TESTING=off | ||
| -DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
| -DCMAKE_C_FLAGS=${{ matrix.compile_flags }} | ||
| -DCMAKE_CXX_FLAGS=${{ matrix.compile_flags }} | ||
| -DCMAKE_EXE_LINKER_FLAGS=${{ matrix.link_flags }} | ||
| -DCMAKE_SHARED_LINKER_FLAGS=${{ matrix.link_flags }} | ||
|
|
||
| - name: Retrieve googletest v${{ env.GOOGLETEST_VERSION }} | ||
| run: | | ||
| wget https://github.com/google/googletest/releases/download/v${{ env.GOOGLETEST_VERSION }}/googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz | ||
| tar -xzvf googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz | ||
| echo GOOGLETEST_ROOT=${{ runner.temp }}/googletest-${{ env.GOOGLETEST_VERSION }} >> $GITHUB_ENV | ||
| working-directory: ${{ runner.temp }} | ||
|
|
||
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Configure sanitizer environment | ||
| run: | | ||
| if command -v llvm-symbolizer >/dev/null 2>&1; then | ||
| echo LLVM_SYMBOLIZER_PATH=$(command -v llvm-symbolizer) >> $GITHUB_ENV | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this for and what uses it? |
||
| fi | ||
|
|
||
| - name: Configure CMake | ||
| run: | | ||
| cmake -S . -B build \ | ||
| -DCMAKE_BUILD_TYPE=RelWithDebInfo \ | ||
| -DCMAKE_CXX_STANDARD=17 \ | ||
| -DCMAKE_PREFIX_PATH=/usr/local/ \ | ||
| -DGOOGLETEST_ROOT=${{ env.GOOGLETEST_ROOT }} \ | ||
| -DGOOGLETEST_VERSION=${{ env.GOOGLETEST_VERSION }} \ | ||
| -DCMAKE_C_FLAGS="${{ matrix.compile_flags }}" \ | ||
| -DCMAKE_CXX_FLAGS="${{ matrix.compile_flags }}" \ | ||
| -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.link_flags }}" \ | ||
| -DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.link_flags }}" | ||
|
|
||
| - name: Build | ||
| run: cmake --build build --parallel 45 | ||
|
|
||
| - name: Test | ||
| run: cmake --build build --parallel 45 --target test | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: ON | ||
| CTEST_PARALLEL_LEVEL: 45 | ||
| ASAN_OPTIONS: ${{ matrix.sanitizer == 'address' && 'detect_leaks=1' || '' }} | ||
| TSAN_OPTIONS: ${{ matrix.sanitizer == 'thread' && 'halt_on_error=1' || '' }} | ||
| MSAN_OPTIONS: ${{ matrix.sanitizer == 'memory' && 'exitcode=1' || '' }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about -fsanitize=address,undefined here? Merge the UBSAN and ASAN together? UBSAN is the one that catches a lot of errors during testing for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
-fsanitize=address,undefined,local-bounds,nullabilitylooks good.https://github.com/google/s2geometry/actions/runs/18301785002/job/53309264384?pr=461#step:3:143