Skip to content

Commit

Permalink
Run asan in CI. Fixes #713
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Chiovoloni authored and thomcc committed Apr 16, 2020
1 parent 4abc8a4 commit 185899e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ jobs:
set RUSTFLAGS=-Ctarget-feature=+crt-static
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.
clippy:
name: Clippy
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ extra_check = []
modern_sqlite = ["libsqlite3-sys/bundled_bindings"]
in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"]
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
# features or dependencies. This is useful for running tests / clippy / etc. New
Expand Down
1 change: 1 addition & 0 deletions libsqlite3-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ preupdate_hook = []
# 3.13.0
session = ["preupdate_hook"]
in_gecko = []
with-asan = []

[build-dependencies]
bindgen = { version = "0.53", optional = true, default-features = false, features = ["runtime"] }
Expand Down
5 changes: 5 additions & 0 deletions libsqlite3-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ mod build_bundled {
.flag("-DSQLITE_USE_URI")
.flag("-DHAVE_USLEEP=1")
.warnings(false);

if cfg!(feature = "with-asan") {
cfg.flag("-fsanitize=address");
}

// Older versions of visual studio don't support c99 (including isnan), which
// causes a build failure when the linker fails to find the `isnan`
// function. `sqlite` provides its own implmentation, using the fact
Expand Down

0 comments on commit 185899e

Please sign in to comment.