Skip to content

Commit

Permalink
Add AddressSanitizer
Browse files Browse the repository at this point in the history
Do not override the compilers (the CC and CXX environment variables).
For some reason, using CC=clang and CXX=clang++ (Clang 14.0.0) with
AddressSanitixer results in segmentation faults in the ubuntu-latest os
image.
  • Loading branch information
wantehchang committed Mar 20, 2024
1 parent edd02ee commit d1ec2ef
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/ci-unix-static-sanitized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
sanitizer: [ undefined ] # TODO(yguyon): Add address, memory, thread

env:
CC: clang
CXX: clang++
sanitizer: [ address, undefined ] # TODO(yguyon): Add memory, thread

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -28,35 +24,39 @@ jobs:
- uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
with:
version: 2.15.05
env:
CC: clang
CXX: clang++
- uses: seanmiddleditch/gha-setup-ninja@8b297075da4cd2a5f1fd21fe011b499edf06e9d2 # v4
- run: pip install meson

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
with:
path: ext
key: ${{ runner.os }}-${{ matrix.sanitizer }}-${{ hashFiles('ext/*.cmd') }}

- name: Build aom
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: >
sed -i -e 's/cmake -G Ninja \(.*\) \.\./cmake -G Ninja \1 -DSANITIZE=${{ matrix.sanitizer }} ../g' aom.cmd
./aom.cmd
env:
CC: clang
CXX: clang++
- name: Build dav1d
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: >
sed -i -e 's/meson setup \(.*\) \.\./meson setup \1 '"-Db_sanitize=${{ matrix.sanitizer }} -Db_lundef=false"' ../g' dav1d.cmd
./dav1d.cmd
env:
CC: clang
CXX: clang++
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: ./libyuv.cmd
env:
CC: clang
CXX: clang++
CFLAGS: -fsanitize=${{ matrix.sanitizer }}
CXXFLAGS: -fsanitize=${{ matrix.sanitizer }}
LDFLAGS: -fsanitize=${{ matrix.sanitizer }}
Expand All @@ -65,6 +65,8 @@ jobs:
working-directory: ./ext
run: ./libsharpyuv.cmd
env:
CC: clang
CXX: clang++
CFLAGS: -fsanitize=${{ matrix.sanitizer }}
CXXFLAGS: -fsanitize=${{ matrix.sanitizer }}
LDFLAGS: -fsanitize=${{ matrix.sanitizer }}
Expand All @@ -73,6 +75,9 @@ jobs:
working-directory: ./ext
# Note: "apt install googletest" is sometimes insufficient for find_package(GTest) so build in ext/ instead.
run: bash -e googletest.cmd
env:
CC: clang
CXX: clang++

- name: Prepare libavif (cmake)
run: >
Expand All @@ -83,6 +88,8 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON
env:
CC: clang
CXX: clang++
CFLAGS: -fsanitize=${{ matrix.sanitizer }}
CXXFLAGS: -fsanitize=${{ matrix.sanitizer }}
LDFLAGS: -fsanitize=${{ matrix.sanitizer }}
Expand All @@ -91,5 +98,6 @@ jobs:
run: ninja
- name: Run AVIF Tests
working-directory: ./build
# ASAN_OPTIONS=allocator_may_return_null=1 may be necessary for address sanitizer.
run: ctest -j $(getconf _NPROCESSORS_ONLN) --output-on-failure
env:
ASAN_OPTIONS: allocator_may_return_null=1

0 comments on commit d1ec2ef

Please sign in to comment.