From fd5960a6539efc42e1930c58d4e291b9cabf1722 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sat, 9 Sep 2017 06:10:58 +0000 Subject: [PATCH] [ubsan] Enable UBsan in sanitizer_common tests Summary: Failing tests just marked as UNSUPPORTED or XFAIL. Some of them can be easily supported, but I'll do this in separate patches. Reviewers: eugenis, alekseyshl Subscribers: srhines, kubamracek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D37630 llvm-svn: 312860 --- compiler-rt/test/sanitizer_common/CMakeLists.txt | 1 + .../sanitizer_common/TestCases/Linux/allow_user_segv.cc | 1 + compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc | 1 + .../sanitizer_common/TestCases/Linux/decorate_proc_maps.cc | 3 ++- .../test/sanitizer_common/TestCases/Linux/deepbind.cc | 2 +- .../TestCases/Linux/hard_rss_limit_mb_test.cc | 1 + compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc | 1 + .../test/sanitizer_common/TestCases/Linux/mlock_test.cc | 2 +- compiler-rt/test/sanitizer_common/TestCases/Linux/mprobe.cc | 2 +- .../test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc | 2 +- .../TestCases/Linux/soft_rss_limit_mb_test.cc | 1 + .../TestCases/Linux/unexpected_format_specifier_test.cc | 1 + .../TestCases/Posix/dedup_token_length_test.cc | 1 + compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc | 1 + .../TestCases/Posix/sanitizer_set_death_callback_test.cc | 1 + .../TestCases/Posix/sanitizer_set_report_fd_test.cc | 1 + .../test/sanitizer_common/TestCases/Posix/weak_hook_test.cc | 1 + compiler-rt/test/sanitizer_common/TestCases/corelimit.cc | 2 +- compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc | 1 + .../test/sanitizer_common/TestCases/options-include.cc | 1 + .../test/sanitizer_common/TestCases/print-stack-trace.cc | 1 + .../TestCases/sanitizer_coverage_no_prune.cc | 2 +- .../TestCases/sanitizer_coverage_trace_pc_guard-dso.cc | 5 +++-- .../TestCases/sanitizer_coverage_trace_pc_guard.cc | 6 +++--- compiler-rt/test/sanitizer_common/lit.common.cfg | 3 +++ 25 files changed, 32 insertions(+), 12 deletions(-) diff --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt index b716f89df45f..2a3d7a0383b6 100644 --- a/compiler-rt/test/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt @@ -11,6 +11,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID) list(APPEND SUPPORTED_TOOLS tsan) list(APPEND SUPPORTED_TOOLS msan) list(APPEND SUPPORTED_TOOLS lsan) + list(APPEND SUPPORTED_TOOLS ubsan) endif() # Create a separate config for each tool we support. diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc index 628c8e3f0cb1..4fe3c32f0e5d 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc @@ -21,6 +21,7 @@ // UNSUPPORTED: lsan // UNSUPPORTED: msan // UNSUPPORTED: tsan +// UNSUPPORTED: ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc index 5d58ea4f7e81..7422d400a811 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc @@ -7,6 +7,7 @@ // XFAIL: msan // XFAIL: lsan // XFAIL: tsan +// XFAIL: ubsan #include #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/decorate_proc_maps.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/decorate_proc_maps.cc index 36d4df567ee7..88275755faae 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/decorate_proc_maps.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/decorate_proc_maps.cc @@ -57,5 +57,6 @@ int main(void) { // CHECK-tsan: rw-p {{.*}} [trace 1] // CHECK-tsan: rw-p {{.*}} [trace header 1] -// Nothing interesting with standalone LSan. +// Nothing interesting with standalone LSan and UBSan. // CHECK-lsan: decorate_proc_maps +// CHECK-ubsan: decorate_proc_maps diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/deepbind.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/deepbind.cc index fc810ad039f4..81150fae977e 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/deepbind.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/deepbind.cc @@ -1,5 +1,5 @@ // RUN: %clangxx %s -o %t && %run not %t 1 2>&1 | FileCheck %s -// UNSUPPORTED: lsan, android +// UNSUPPORTED: lsan,ubsan,android #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc index d4a60a0d3731..5c8e19a4f3b3 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc @@ -14,6 +14,7 @@ // XFAIL: lsan // XFAIL: tsan // XFAIL: msan +// XFAIL: ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc index 2c69618ad7cb..2707fc9af715 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc @@ -7,6 +7,7 @@ // XFAIL: msan // XFAIL: lsan // XFAIL: tsan +// XFAIL: ubsan // // FIXME: seems to fail on ARM // REQUIRES: x86_64-target-arch diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cc index 69ea7cb91c4f..a952922aaabc 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cc @@ -1,5 +1,5 @@ // RUN: %clang %s -o %t && %run %t -// XFAIL: lsan +// XFAIL: ubsan,lsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/mprobe.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/mprobe.cc index 57e5ba5a6c74..82c0faf0e2ad 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/mprobe.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/mprobe.cc @@ -1,5 +1,5 @@ // RUN: %clangxx %s -o %t && %run %t 2>&1 | FileCheck %s -// UNSUPPORTED: android +// UNSUPPORTED: android, ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc index b7e8721a1b9e..523ac98117f4 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc @@ -1,7 +1,7 @@ // RUN: %clangxx -O0 -g %s -lutil -o %t && %run %t // This test depends on the glibc layout of struct sem_t and checks that we // don't leave sem_t::private uninitialized. -// UNSUPPORTED: android, lsan-x86 +// UNSUPPORTED: android, lsan-x86, ubsan #include #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cc index 83570a9f13a4..2ee809547530 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cc @@ -14,6 +14,7 @@ // XFAIL: lsan // XFAIL: tsan // XFAIL: msan +// XFAIL: ubsan #include #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc index f48cce8ea22b..641495508ba1 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc @@ -1,6 +1,7 @@ // RUN: %clang -w -O0 %s -o %t && %run %t 2>&1 | FileCheck %s // UNSUPPORTED: lsan // UNSUPPORTED: msan +// UNSUPPORTED: ubsan #include int main() { int a; diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc index 261295790836..ad94d13d2e48 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc @@ -11,6 +11,7 @@ // XFAIL: msan // XFAIL: lsan // XFAIL: tsan +// XFAIL: ubsan volatile int *null = 0; diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc index 9a6f808a5cd7..44d53274bc40 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc @@ -7,6 +7,7 @@ // XFAIL: msan // XFAIL: lsan // XFAIL: tsan +// XFAIL: ubsan // // FIXME: seems to fail on ARM // REQUIRES: x86_64-target-arch diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc index 12a56c73e049..8d2db364114a 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc @@ -8,6 +8,7 @@ // the last line of main function. The problem doesn't reproduce with ASan because // quarantine prohibits memory block reuse for different allocations. // XFAIL: lsan-x86 +// XFAIL: ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc index af7eea1d7de2..5c5d3fb4bcac 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc @@ -9,6 +9,7 @@ // XFAIL: msan // XFAIL: lsan // XFAIL: tsan +// XFAIL: ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/weak_hook_test.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/weak_hook_test.cc index d5667649bb9c..9176a524dbe8 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/weak_hook_test.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/weak_hook_test.cc @@ -4,6 +4,7 @@ // Hooks are not implemented for lsan. // XFAIL: lsan +// XFAIL: ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/corelimit.cc b/compiler-rt/test/sanitizer_common/TestCases/corelimit.cc index 0a86e5b7b7fe..eb02afc01a1b 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/corelimit.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/corelimit.cc @@ -1,5 +1,5 @@ // RUN: %clangxx -O0 %s -o %t && %run %t -// UNSUPPORTED: lsan +// UNSUPPORTED: lsan,ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc b/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc index 59cd620b3f63..853bb66ac5c4 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc @@ -2,6 +2,7 @@ // Malloc/free hooks are not supported on Windows. // XFAIL: win32 +// XFAIL: ubsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/options-include.cc b/compiler-rt/test/sanitizer_common/TestCases/options-include.cc index 5b0b6d52585a..8b131a78571d 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/options-include.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/options-include.cc @@ -1,4 +1,5 @@ // RUN: %clangxx -O0 %s -o %t +// UNSUPPORTED: ubsan // Recursive include: options1 includes options2 // RUN: echo "symbolize=1" > %t.options1.txt diff --git a/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc b/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc index a6eca0b75102..df7cc050a04e 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc @@ -4,6 +4,7 @@ // RUN: %env_tool_opts=symbolize_inline_frames=false:stack_trace_format=DEFAULT %run %t 2>&1 | FileCheck %s --check-prefix=NOINLINE // UNSUPPORTED: darwin +// XFAIL: ubsan #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cc b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cc index 8751930345e5..5e3825d068b2 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cc @@ -2,7 +2,7 @@ // // REQUIRES: has_sancovcc,stable-runtime // UNSUPPORTED: i386-darwin -// XFAIL: tsan +// XFAIL: ubsan,tsan // // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=trace-pc,bb,no-prune 2>&1 | grep "call void @__sanitizer_cov_trace_pc" | count 3 // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=trace-pc,bb 2>&1 | grep "call void @__sanitizer_cov_trace_pc" | count 2 diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc index 6185177a169a..e2934964dd15 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc @@ -1,6 +1,7 @@ // Tests trace pc guard coverage collection. // // REQUIRES: has_sancovcc,stable-runtime +// UNSUPPORTED: ubsan // XFAIL: tsan,darwin,powerpc64,s390x,mips // // RUN: DIR=%t_workdir @@ -68,5 +69,5 @@ int baz() { // // CHECK-SANCOV: Ignoring {{.*}}_1.so and its coverage because __sanitizer_cov* functions were not found. // CHECK-SANCOV: Ignoring {{.*}}_2.so and its coverage because __sanitizer_cov* functions were not found. -// CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cc:29 foo -// CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cc:34 main +// CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cc:[[@LINE-42]] foo +// CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cc:[[@LINE-38]] main diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc index 2d6d00b6a0cd..5740f26949cc 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc @@ -1,7 +1,7 @@ // Tests trace pc guard coverage collection. // // REQUIRES: has_sancovcc,stable-runtime -// UNSUPPORTED: i386-darwin +// UNSUPPORTED: ubsan,i386-darwin // XFAIL: tsan,powerpc64,s390x,mips // // RUN: DIR=%t_workdir @@ -36,7 +36,7 @@ int main() { // CHECK-NEXT: foo // CHECK-NEXT: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard.{{.*}}.sancov: 2 PCs written // -// CHECK-SANCOV: sanitizer_coverage_trace_pc_guard.cc:23 foo -// CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard.cc:28 main +// CHECK-SANCOV: sanitizer_coverage_trace_pc_guard.cc:[[@LINE-16]] foo +// CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard.cc:[[@LINE-12]] main // // CHECK-NOCOV-NOT: SanitizerCoverage diff --git a/compiler-rt/test/sanitizer_common/lit.common.cfg b/compiler-rt/test/sanitizer_common/lit.common.cfg index 307a33ae70f4..7e3e6601107c 100644 --- a/compiler-rt/test/sanitizer_common/lit.common.cfg +++ b/compiler-rt/test/sanitizer_common/lit.common.cfg @@ -18,6 +18,9 @@ elif config.tool_name == "msan": elif config.tool_name == "lsan": tool_cflags = ["-fsanitize=leak"] tool_options = "LSAN_OPTIONS" +elif config.tool_name == "ubsan": + tool_cflags = ["-fsanitize=undefined"] + tool_options = "UBSAN_OPTIONS" else: lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name)