Skip to content

Commit c3e9712

Browse files
committed
add asan
1 parent 0b16945 commit c3e9712

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/CI.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,79 @@ jobs:
6969
run: cargo miri test
7070
env:
7171
MIRIFLAGS: "-Zmiri-disable-isolation"
72+
73+
asan:
74+
name: ASAN - ${{ matrix.os }}
75+
runs-on: ${{ matrix.os }}
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
os: [ubuntu-24.04, windows-latest]
80+
81+
steps:
82+
- uses: actions/checkout@v5
83+
84+
- name: Setup node
85+
uses: actions/setup-node@v5
86+
with:
87+
node-version: 22
88+
cache: 'yarn'
89+
90+
- name: Install Rust
91+
uses: dtolnay/rust-toolchain@stable
92+
with:
93+
toolchain: nightly
94+
components: rust-src
95+
96+
- name: Install dependencies
97+
run: yarn install --immutable --mode=skip-build
98+
99+
- name: Download fixtures
100+
run: node download-fixtures.js
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
104+
- name: Test with ASAN (Linux)
105+
if: matrix.os == 'ubuntu-24.04'
106+
run: cargo test -Zbuild-std --target x86_64-unknown-linux-gnu
107+
env:
108+
RUST_TARGET: x86_64-unknown-linux-gnu
109+
RUST_BACKTRACE: 1
110+
RUSTFLAGS: -Z sanitizer=address
111+
ASAN_OPTIONS: detect_leaks=1
112+
CARGO_UNSTABLE_BUILD_STD: std,panic_abort
113+
114+
- name: Test with ASAN (Windows)
115+
if: matrix.os == 'windows-latest'
116+
shell: pwsh
117+
run: |
118+
# Set ASAN environment variables for Windows
119+
$env:ASAN_OPTIONS = "windows_hook_rtl_allocators=true:detect_leaks=0:print_stats=1:check_initialization_order=true:strict_string_checks=true"
120+
121+
# Find and set the path to the ASAN runtime DLL
122+
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
123+
$asanDllPath = Get-ChildItem -Path "$vsPath\VC\Tools\MSVC" -Recurse -Filter "clang_rt.asan_dynamic-x86_64.dll" | Select-Object -First 1
124+
if ($asanDllPath) {
125+
$env:PATH = "$($asanDllPath.DirectoryName);$env:PATH"
126+
Write-Host "Found ASAN DLL at: $($asanDllPath.FullName)"
127+
}
128+
cargo test --target x86_64-pc-windows-msvc
129+
env:
130+
RUSTFLAGS: -Zsanitizer=address
131+
RUSTDOCFLAGS: -Zsanitizer=address
132+
RUST_BACKTRACE: 1
133+
CARGO_PROFILE_DEV_OPT_LEVEL: 1
134+
CARGO_UNSTABLE_BUILD_STD: std,panic_abort
135+
136+
- name: Upload ASAN logs (Windows)
137+
if: failure() && matrix.os == 'windows-latest'
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: windows-asan-logs
141+
path: |
142+
asan.log*
143+
*.asan.log
144+
72145
bench:
73146
strategy:
74147
matrix:

0 commit comments

Comments
 (0)