Skip to content

Sanitizers

Sanitizers #2072

Workflow file for this run

name: Linux
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -e -l {0}
jobs:
build:
runs-on: ${{ matrix.sys.image }}
name: ${{ matrix.sys.compiler }} / ${{ matrix.sys.version }} / ${{ matrix.sys.stdlib }} / ${{ matrix.config.name }} / date-polyfill ${{ matrix.sys.date-polyfill}}
env:
SCCACHE_GHA_ENABLED: "true"
strategy:
fail-fast: false
matrix:
sys:
- {image: ubuntu-24.04, compiler: clang, version: '17', config-flags: '', stdlib: 'libstdc++-12', date-polyfill: 'ON'}
# - {compiler: clang, version: '17', config-flags: '-DCMAKE_CXX_FLAGS=-stdlib=libc++', stdlib: 'libc++-17', date-polyfill: 'ON' }
- {image: ubuntu-24.04, compiler: clang, version: '18', config-flags: '', stdlib: 'libstdc++-12', date-polyfill: 'ON'}
# - {compiler: clang, version: '16', config-flags: '-DCMAKE_CXX_FLAGS=-stdlib=libc++', stdlib: 'libc++-17', date-polyfill: 'ON' }
- {image: ubuntu-24.04, compiler: gcc, version: '12', config-flags: '', date-polyfill: 'ON'}
- {image: ubuntu-24.04, compiler: gcc, version: '13', config-flags: '', date-polyfill: 'ON'}
- {image: ubuntu-24.04, compiler: gcc, version: '13', config-flags: '', date-polyfill: 'OFF'}
config:
- {name: Debug}
- {name: Release}
steps:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install GCC
if: matrix.sys.compiler == 'gcc'
uses: egor-tensin/setup-gcc@v1
with:
version: ${{matrix.sys.version}}
platform: x64
- name: Install LLVM and Clang
if: matrix.sys.compiler == 'clang'
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{matrix.sys.version}}
arch: x64
- name: Install the specified standard library for clang
if: matrix.sys.compiler == 'clang'
run: sudo apt install ${{matrix.sys.stdlib}}-dev -y
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout nanoarrow
uses: actions/checkout@v4
with:
repository: apache/arrow-nanoarrow
path: dependencies/tests/nanoarrow
- name: Set conda environment
uses: mamba-org/setup-micromamba@main
with:
environment-name: myenv
environment-file: environment-dev.yml
init-shell: bash
cache-downloads: true
- name: Configure nanoarrow
working-directory: dependencies/tests/nanoarrow
run: |
cmake -G Ninja \
-Bbuild \
${{matrix.sys.config-flags}} \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
- name: Build nanoarrow
working-directory: dependencies/tests/nanoarrow/build
run: cmake --build . --config ${{matrix.config.name}} --target install
- name: Configure using CMake
run: |
cmake -G Ninja \
-Bbuild ${{matrix.sys.config-flags}} \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DUSE_DATE_POLYFILL=${{matrix.sys.date-polyfill}} \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DUSE_SANITIZER="address;undefined;leak"
- name: Build library
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target sparrow --parallel 8
- name: Install
working-directory: build
run: cmake --install . --config ${{matrix.config.name}}
- name: Build tests
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target test_sparrow_lib --parallel 8
- name: fine-tune asan options
# in asan we get an error from std::regex. ignore it.
run: |
echo "ASAN_OPTIONS=log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0:exitcode=0" >> $GITHUB_ENV
echo "LEAK_OPTIONS=log_path=leak_log_" >> $GITHUB_ENV
- name: Run sccache stat for check
shell: bash
run: ${SCCACHE_PATH} --show-stats
- name: Run tests
working-directory: build
run: |
export ASAN_OPTIONS=log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0:exitcode=0
export LEAK_OPTIONS=log_path=leak_log_
cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report
# env:
# # log_path is set to the path where ASAN will write the error report (seems ineffective)
# # alloc_dealloc_mismatch is set to 0 to deactivate unwanted ASAN warnings.
# # halt_on_error is set to 0 to avoid crashing the program after printing the first error report.
# # handle_abort is set to 0 to deactivate calls are handled as crashes by ASAN.
# # exitcode is set to 0 to avoid reporting the build as failed if ASAN detects an error.
# ASAN_OPTIONS: log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0:exitcode=0
# LEAK_OPTIONS: log_path=leak_log_
- name: Upload test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test_sparrow_lib_report_Linux_${{ matrix.sys.compiler }}_${{ matrix.sys.version }}_${{ matrix.sys.stdlib }}_${{ matrix.config.name }}_date-polyfill_${{ matrix.sys.date-polyfill}}
path: '**/test_sparrow_lib_report.xml'
- name: Upload ASAN log
if: always()
uses: actions/upload-artifact@v4
with:
name: asan-log-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.config.name }}-${{ matrix.sys.date-polyfill }}
path: '**/asan_log_*'
- name: Upload LEAK log
if: always()
uses: actions/upload-artifact@v4
with:
name: leak-log-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.config.name }}-${{ matrix.sys.date-polyfill }}
path: '**/leak_log_*'
- name: Run all examples
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target run_examples