diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8448d5571..489dd211e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -232,8 +232,8 @@ jobs: run: rustup component add rust-src - name: "Set dependencies" run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock - - name: "Run test script" - run: ./contrib/run_task.sh asan + - name: "Run sanitizer script" + run: cd ./hashes && ./contrib/sanitizer.sh WASM: # hashes crate only. name: WASM - stable toolchain diff --git a/contrib/run_task.sh b/contrib/run_task.sh index 2bb10dddc..1c7c54d1c 100755 --- a/contrib/run_task.sh +++ b/contrib/run_task.sh @@ -90,11 +90,6 @@ main() { do_bench ;; - asan) - # hashes crate only - hashes/contrib/test_vars.sh is sourced in this function. - do_asan - ;; - *) err "Error: unknown task $task" ;; @@ -254,27 +249,6 @@ do_bench() { done } -do_asan() { - pushd "$REPO_DIR/hashes" > /dev/null - - # Set ASAN_FEATURES - . contrib/test_vars.sh || exit 1 - - cargo clean - CC='clang -fsanitize=address -fno-omit-frame-pointer' \ - RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \ - ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \ - cargo test --lib --no-default-features --features="$ASAN_FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu - # There is currently a bug in the MemorySanitizer (MSAN) - disable the job for now. - # - # cargo clean - # CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ - # RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \ - # cargo test --lib --no-default-features --features="$ASAN_FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu - - popd > /dev/null -} - # Check all the commands we use are present in the current environment. check_required_commands() { need_cmd cargo diff --git a/hashes/contrib/sanitizer.sh b/hashes/contrib/sanitizer.sh new file mode 100755 index 000000000..5a1e56c2f --- /dev/null +++ b/hashes/contrib/sanitizer.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Run the Address/Memory Sanitizer tests. + +set -euox pipefail + +# Run the sanitizer with these features. +FEATURES="std io serde" + +cargo clean +CC='clang -fsanitize=address -fno-omit-frame-pointer' \ + RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \ + ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \ + cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu + +# There is currently a bug in the MemorySanitizer (MSAN) - disable the job for now. +# +# cargo clean +# CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ + # RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \ + # cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu diff --git a/hashes/contrib/test_vars.sh b/hashes/contrib/test_vars.sh index 5e89c21e7..d4073ddbe 100644 --- a/hashes/contrib/test_vars.sh +++ b/hashes/contrib/test_vars.sh @@ -6,8 +6,5 @@ FEATURES_WITH_STD="io serde small-hash schemars" # Test all these features without "std" enabled. FEATURES_WITHOUT_STD="alloc serde small-hash" -# Run address sanitizer with these features. -ASAN_FEATURES="std io serde" - # Run these examples. EXAMPLES=""