Run asan in CI. Fixes #713

This commit is contained in:
Thom Chiovoloni 2020-04-16 02:38:40 -07:00 committed by Thom Chiovoloni
parent 4abc8a4fdd
commit 185899eab1
4 changed files with 26 additions and 0 deletions

View File

@ -68,6 +68,24 @@ jobs:
set RUSTFLAGS=-Ctarget-feature=+crt-static set RUSTFLAGS=-Ctarget-feature=+crt-static
cargo build --features bundled cargo build --features bundled
sanitizer:
name: Address Sanitizer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Need nightly rust.
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rust-src
- name: Tests with asan
env:
RUSTFLAGS: -Zsanitizer=address
RUSTDOCFLAGS: -Zsanitizer=address
run: cargo -Z build-std test --features 'bundled-full session buildtime_bindgen with-asan' --target x86_64-unknown-linux-gnu
# Ensure clippy doesn't complain. # Ensure clippy doesn't complain.
clippy: clippy:
name: Clippy name: Clippy

View File

@ -57,6 +57,8 @@ extra_check = []
modern_sqlite = ["libsqlite3-sys/bundled_bindings"] modern_sqlite = ["libsqlite3-sys/bundled_bindings"]
in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"] in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"]
bundled-windows = ["libsqlite3-sys/bundled-windows"] bundled-windows = ["libsqlite3-sys/bundled-windows"]
# Build bundled sqlite with -fsanitize=address
with-asan = ["libsqlite3-sys/with-asan"]
# Helper feature for enabling both `bundled` and most non-build-related optional # Helper feature for enabling both `bundled` and most non-build-related optional
# features or dependencies. This is useful for running tests / clippy / etc. New # features or dependencies. This is useful for running tests / clippy / etc. New

View File

@ -31,6 +31,7 @@ preupdate_hook = []
# 3.13.0 # 3.13.0
session = ["preupdate_hook"] session = ["preupdate_hook"]
in_gecko = [] in_gecko = []
with-asan = []
[build-dependencies] [build-dependencies]
bindgen = { version = "0.53", optional = true, default-features = false, features = ["runtime"] } bindgen = { version = "0.53", optional = true, default-features = false, features = ["runtime"] }

View File

@ -80,6 +80,11 @@ mod build_bundled {
.flag("-DSQLITE_USE_URI") .flag("-DSQLITE_USE_URI")
.flag("-DHAVE_USLEEP=1") .flag("-DHAVE_USLEEP=1")
.warnings(false); .warnings(false);
if cfg!(feature = "with-asan") {
cfg.flag("-fsanitize=address");
}
// Older versions of visual studio don't support c99 (including isnan), which // Older versions of visual studio don't support c99 (including isnan), which
// causes a build failure when the linker fails to find the `isnan` // causes a build failure when the linker fails to find the `isnan`
// function. `sqlite` provides its own implmentation, using the fact // function. `sqlite` provides its own implmentation, using the fact