From 34d5c756721def8c562789091ab39e3042841ed8 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 23 Jan 2023 09:46:48 +1100 Subject: [PATCH] Overcome ASAN false positive regression The Memory Sanitizer is giving a false positive at the moment in `nightly`. Adding compiler flags resolves the issue. I didn't grok the exact root cause but this fixes it (cut'n'pasta from the issue [0]). [0] https://github.com/rust-lang/rust/issues/107149 --- contrib/test.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/test.sh b/contrib/test.sh index 38730d6d3..15106c6bf 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -73,16 +73,19 @@ if [ "$DO_WASM" = true ]; then fi # Address Sanitizer +# +# The -Cllvm-args=-msan-eager-checks=0 flag was added to overcome this issue: +# https://github.com/rust-bitcoin/rust-secp256k1/pull/573#issuecomment-1399465995 if [ "$DO_ASAN" = true ]; then clang --version 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' \ + CC='clang -fsanitize=address -fno-omit-frame-pointer' \ + RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \ + ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \ cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu cargo clean - CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ - RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \ + CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ + RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \ cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully" cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"