From a2f0d7507c2fb87096c74582d05cdfc05c6e3e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Sat, 25 Nov 2017 15:17:19 +0100 Subject: [PATCH] properly handle -fsanitize-blacklist= --- client/arg.cpp | 18 +++++++++++---- client/main.cpp | 2 +- tests/fsanitize-blacklist.txt | 1 + tests/fsanitize.cpp | 4 ++-- tests/test.sh | 41 ++++++++++++++++++++++++++++++++++- 5 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 tests/fsanitize-blacklist.txt diff --git a/client/arg.cpp b/client/arg.cpp index b137d1bd6..9df6e2e0a 100644 --- a/client/arg.cpp +++ b/client/arg.cpp @@ -521,18 +521,28 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, listsend_msg(GetNativeEnvMsg(compiler_is_clang(job) diff --git a/tests/fsanitize-blacklist.txt b/tests/fsanitize-blacklist.txt new file mode 100644 index 000000000..447cf7846 --- /dev/null +++ b/tests/fsanitize-blacklist.txt @@ -0,0 +1 @@ +fun:*test_fsanitize_function* diff --git a/tests/fsanitize.cpp b/tests/fsanitize.cpp index 2ed296d41..ec478eb4f 100644 --- a/tests/fsanitize.cpp +++ b/tests/fsanitize.cpp @@ -1,4 +1,4 @@ -void test() +void test_fsanitize_function() { int* arr = new int[10]; delete[] arr; @@ -8,6 +8,6 @@ void test() int main() { - test(); + test_fsanitize_function(); return 0; } diff --git a/tests/test.sh b/tests/test.sh index d1df25cd6..eaa83b8b8 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1018,6 +1018,16 @@ check_log_error() fi } +check_section_log_error() +{ + log="$1" + if grep -q "$2" "$testdir"/${log}.log "$testdir"/${log}_section.log; then + echo "Error, $log log contains error: $2" + stop_ice 0 + abort_tests + fi +} + # check the error message ($2) is not present in log ($1), # but the exception ($3) is allowed check_log_error_except() @@ -1040,6 +1050,16 @@ check_log_message() fi } +check_section_log_message() +{ + log="$1" + if ! grep -q "$2" "$testdir"/${log}.log "$testdir"/${log}_section.log; then + echo "Error, $log log does not contain: $2" + stop_ice 0 + abort_tests + fi +} + check_log_message_count() { log="$1" @@ -1134,8 +1154,27 @@ if $GXX -fsanitize=address -c -fsyntax-only -Werror fsanitize.cpp >/dev/null 2>/ fi "$testdir"/fsanitize 2>>"$testdir"/stderr.log check_log_message stderr "ERROR: AddressSanitizer: heap-use-after-free" - check_log_message stderr "SUMMARY: AddressSanitizer: heap-use-after-free .*/fsanitize.cpp:5 in test()" + check_log_message stderr "SUMMARY: AddressSanitizer: heap-use-after-free .*/fsanitize.cpp:5 in test_fsanitize_function()" rm "$testdir"/fsanitize.o + + if $GXX -fsanitize=address -fsanitize-blacklist=fsanitize-blacklist.txt -c -fsyntax-only fsanitize.cpp >/dev/null 2>/dev/null; then + run_ice "" "local" 300 $GXX -c -fsanitize=address -fsanitize-blacklist=nonexistent -g fsanitize.cpp -o "$testdir"/fsanitize.o + check_section_log_message icecc "file for argument -fsanitize-blacklist=nonexistent missing, building locally" + + run_ice "$testdir/fsanitize.o" "remote" 0 keepoutput $GXX -c -fsanitize=address -fsanitize-blacklist=fsanitize-blacklist.txt -g fsanitize.cpp -o "$testdir"/fsanitize.o + $GXX -fsanitize=address -fsanitize-blacklist=fsanitize-blacklist.txt -g "$testdir"/fsanitize.o -o "$testdir"/fsanitize 2>>"$testdir"/stderr.log + if test $? -ne 0; then + echo "Linking for -fsanitize test failed." + stop_ice 0 + abort_tests + fi + "$testdir"/fsanitize 2>>"$testdir"/stderr.log + check_log_error stderr "ERROR: AddressSanitizer: heap-use-after-free" + check_log_error stderr "SUMMARY: AddressSanitizer: heap-use-after-free .*/fsanitize.cpp:5 in test()" + rm "$testdir"/fsanitize.o + else + skipped_tests="$skipped_tests fsanitize-blacklist" + fi else skipped_tests="$skipped_tests fsanitize" fi