diff --git a/.github/lsan-suppressions.txt b/.github/lsan-suppressions.txt new file mode 100644 index 0000000..e513f92 --- /dev/null +++ b/.github/lsan-suppressions.txt @@ -0,0 +1,6 @@ + +# Intel GPU OpenCL driver initialization allocations. +leak:libigdrcl.so + +# Intel OpenCL adapter queue/event/context leaks reported at process exit. +leak:libur_adapter_opencl.so diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index a126f0e..6e7692a 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -86,6 +86,60 @@ jobs: name: documentation path: target/doc + hardening: + if: github.event_name != 'schedule' + runs-on: ["oneapi-rs", "Linux"] + + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + + - name: Setup oneAPI + uses: ./.github/actions/setup-oneapi + + - name: Install nightly toolchain + run: rustup toolchain install nightly --profile minimal + + - name: Build and test with hardening flags + env: + RUSTFLAGS: -Zemit-stack-sizes -Zcf-protection=full + CARGO_TARGET_DIR: target/hardened + run: | + cargo +nightly test --workspace --verbose + cargo +nightly build --workspace --release --verbose + + sanitizers: + name: Sanitizer (${{ matrix.sanitizer }}) + if: github.event_name != 'schedule' + runs-on: ["oneapi-rs", "Linux"] + strategy: + fail-fast: false + matrix: + # TODO add thread sanitizer + sanitizer: [address, leak] + env: + CARGO_TARGET_DIR: target/sanitizer-${{ matrix.sanitizer }} + + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + + - name: Setup oneAPI + uses: ./.github/actions/setup-oneapi + + - name: Install nightly toolchain + run: rustup toolchain install nightly --profile minimal + + - name: Run tests with sanitizers + env: + # Test only CPU to avoid issues with GPU drivers and sanitizers + ONEAPI_DEVICE_SELECTOR: opencl:cpu + # Leave leak detection to the dedicated leak sanitizer job. + ASAN_OPTIONS: detect_leaks=0 + LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan-suppressions.txt + RUSTFLAGS: -Zsanitizer=${{ matrix.sanitizer }} + run: | + cargo +nightly test \ + --workspace --lib --tests --target x86_64-unknown-linux-gnu --verbose + trivy: name: Trivy scan runs-on: ubuntu-latest