Skip to content

Commit 935d072

Browse files
committed
Use address sanitizer to check for memory errors
1 parent 700f13f commit 935d072

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

.github/workflows/check.yml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,42 @@ jobs:
1111
- uses: actions/checkout@v2
1212
with:
1313
submodules: true
14-
- uses: actions-rs/toolchain@v1
14+
- name: Install stable toolchain
15+
uses: actions-rs/toolchain@v1
1516
with:
1617
components: clippy, rustfmt
17-
default: true
18-
- run: cargo fmt --all -- --check
19-
- run: cargo build --workspace --all-targets --all-features
20-
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings
21-
- run: cargo test --workspace --all-features
18+
- name: Run rustfmt
19+
uses: actions-rs/cargo@v1
20+
with:
21+
command: fmt
22+
args: --all -- --check
23+
- name: Build all targets
24+
uses: actions-rs/cargo@v1
25+
with:
26+
command: build
27+
args: --workspace --all-targets --all-features
28+
- name: Run Clippy linter
29+
uses: actions-rs/cargo@v1
30+
with:
31+
command: clippy
32+
args: --workspace --all-targets --all-features -- -D warnings
33+
- name: Run tests
34+
uses: actions-rs/cargo@v1
35+
with:
36+
command: test
37+
args: --workspace --all-features
38+
- name: Install nightly toolchain
39+
uses: actions-rs/toolchain@v1
40+
with:
41+
toolchain: nightly-2020-08-28
42+
override: true
43+
components: rust-src
44+
- name: Run tests with address sanitizer
45+
uses: actions-rs/cargo@v1
46+
env:
47+
ASAN_SYMBOLIZER_PATH: /usr/lib/llvm-9/bin/llvm-symbolizer
48+
RUSTFLAGS: -Zsanitizer=address
49+
RUSTDOCFLAGS: -Zsanitizer=address
50+
with:
51+
command: test
52+
args: --workspace --all-features --target x86_64-unknown-linux-gnu -Zbuild-std

.github/workflows/publish.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2
11-
- uses: actions-rs/toolchain@v1
12-
with:
13-
default: true
14-
- env:
11+
- name: Install stable toolchain
12+
uses: actions-rs/toolchain@v1
13+
- name: Login to registry
14+
uses: actions-rs/cargo@v1
15+
env:
1516
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
16-
run: cargo login "$CARGO_REGISTRY_TOKEN"
17-
- run: cargo publish
17+
with:
18+
command: login
19+
args: "$CARGO_REGISTRY_TOKEN"
20+
- name: Publish crate
21+
uses: actions-rs/cargo@v1
22+
with:
23+
command: publish

tests/i386.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use memmem::{Searcher, TwoWaySearcher};
21
use std::{
32
fs::{self, File},
43
io::{BufRead, BufReader},
@@ -10,20 +9,10 @@ fn search(haystack: &str, needle: &str) {
109
let haystack = haystack.as_bytes();
1110
let needle = needle.as_bytes();
1211

13-
let searcher = TwoWaySearcher::new(needle);
14-
assert_eq!(searcher.search_in(haystack).is_some(), result);
15-
16-
assert_eq!(twoway::find_bytes(haystack, needle).is_some(), result);
17-
1812
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
1913
{
2014
use sliceslice::x86::DynamicAvx2Searcher;
2115

22-
assert_eq!(
23-
unsafe { sse4_strstr::avx2_strstr_v2(haystack, needle).is_some() },
24-
result
25-
);
26-
2716
let searcher = unsafe { DynamicAvx2Searcher::new(needle.to_owned().into_boxed_slice()) };
2817
assert_eq!(unsafe { searcher.search_in(haystack) }, result);
2918
}

0 commit comments

Comments
 (0)