diff options
Diffstat (limited to 'test/msan')
-rw-r--r-- | test/msan/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/msan/Linux/forkpty.cc | 7 | ||||
-rw-r--r-- | test/msan/Linux/obstack.cc | 4 | ||||
-rw-r--r-- | test/msan/Linux/process_vm_readv.cc | 2 | ||||
-rw-r--r-- | test/msan/Linux/syscalls_sigaction.cc | 8 | ||||
-rw-r--r-- | test/msan/allocator_mapping.cc | 2 | ||||
-rw-r--r-- | test/msan/backtrace.cc | 2 | ||||
-rw-r--r-- | test/msan/chained_origin.cc | 25 | ||||
-rw-r--r-- | test/msan/chained_origin_limits.cc | 26 | ||||
-rw-r--r-- | test/msan/chained_origin_memcpy.cc | 21 | ||||
-rw-r--r-- | test/msan/coverage-levels.cc | 2 | ||||
-rw-r--r-- | test/msan/fork.cc | 7 | ||||
-rw-r--r-- | test/msan/getutent.cc | 17 | ||||
-rw-r--r-- | test/msan/iconv.cc | 2 | ||||
-rw-r--r-- | test/msan/lit.cfg | 8 | ||||
-rw-r--r-- | test/msan/mmap.cc | 10 | ||||
-rw-r--r-- | test/msan/msan_check_mem_is_initialized.cc | 2 | ||||
-rw-r--r-- | test/msan/msan_copy_shadow.cc | 7 | ||||
-rw-r--r-- | test/msan/print_stats.cc | 18 | ||||
-rw-r--r-- | test/msan/realloc-large-origin.cc | 11 | ||||
-rw-r--r-- | test/msan/recover-dso.cc (renamed from test/msan/keep-going-dso.cc) | 30 | ||||
-rw-r--r-- | test/msan/recover.cc (renamed from test/msan/keep-going.cc) | 31 | ||||
-rw-r--r-- | test/msan/strlen_of_shadow.cc | 2 |
23 files changed, 161 insertions, 94 deletions
diff --git a/test/msan/CMakeLists.txt b/test/msan/CMakeLists.txt index 176fb4ae1846..171bcb9618ff 100644 --- a/test/msan/CMakeLists.txt +++ b/test/msan/CMakeLists.txt @@ -10,16 +10,7 @@ endif() foreach(arch ${MSAN_TEST_ARCH}) set(MSAN_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}" MSAN_TEST_CONFIG_SUFFIX) - if(ANDROID OR ${arch} MATCHES "arm|aarch64") - # This is only true if we are cross-compiling. - # Build all tests with host compiler and use host tools. - set(MSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(MSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} MSAN_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " MSAN_TEST_TARGET_CFLAGS "${MSAN_TEST_TARGET_CFLAGS}") - endif() - + get_test_cc_for_arch(${arch} MSAN_TEST_TARGET_CC MSAN_TEST_TARGET_CFLAGS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) diff --git a/test/msan/Linux/forkpty.cc b/test/msan/Linux/forkpty.cc index ae5c7d96ca8a..c9f04376fd74 100644 --- a/test/msan/Linux/forkpty.cc +++ b/test/msan/Linux/forkpty.cc @@ -1,6 +1,9 @@ // RUN: %clangxx_msan -O0 -g %s -lutil -o %t && %run %t + #include <assert.h> #include <pty.h> +#include <unistd.h> +#include <cstring> #include <sanitizer/msan_interface.h> @@ -12,6 +15,10 @@ main (int argc, char** argv) assert(__msan_test_shadow(&master, sizeof(master)) == -1); assert(__msan_test_shadow(&slave, sizeof(slave)) == -1); + char ttyname[255]; + ttyname_r(master, ttyname, sizeof(ttyname)); + assert(__msan_test_shadow(ttyname, strlen(ttyname) + 1) == -1); + int master2; forkpty(&master2, NULL, NULL, NULL); assert(__msan_test_shadow(&master2, sizeof(master2)) == -1); diff --git a/test/msan/Linux/obstack.cc b/test/msan/Linux/obstack.cc index f1f53be4c9b2..0a81d8704f1e 100644 --- a/test/msan/Linux/obstack.cc +++ b/test/msan/Linux/obstack.cc @@ -1,5 +1,5 @@ // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t -// RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t && not %run %t |& FileCheck %s +// RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t && not %run %t 2>&1 | FileCheck %s #include <obstack.h> #include <sanitizer/msan_interface.h> @@ -30,7 +30,7 @@ int main(void) { __msan_check_mem_is_initialized(p, sizeof(data) + 1); } // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value - // CHECK: #0 0x{{.*}} in main{{.*}}obstack.cc:[[@LINE-30]] + // CHECK: #0 0x{{.*}} in main{{.*}}obstack.cc:[[@LINE-3]] #endif } obstack_free(&obs, 0); diff --git a/test/msan/Linux/process_vm_readv.cc b/test/msan/Linux/process_vm_readv.cc index b61578d1bfda..0a0e0274b8a5 100644 --- a/test/msan/Linux/process_vm_readv.cc +++ b/test/msan/Linux/process_vm_readv.cc @@ -1,5 +1,5 @@ // RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t -// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t -DPOSITIVE && not %run %t |& FileCheck %s +// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t -DPOSITIVE && not %run %t 2>&1 | FileCheck %s #include <assert.h> #include <dlfcn.h> diff --git a/test/msan/Linux/syscalls_sigaction.cc b/test/msan/Linux/syscalls_sigaction.cc index 1297fae13d12..975ca2ba6877 100644 --- a/test/msan/Linux/syscalls_sigaction.cc +++ b/test/msan/Linux/syscalls_sigaction.cc @@ -11,7 +11,11 @@ #include <sanitizer/msan_interface.h> struct my_kernel_sigaction { +#if defined(__mips__) + long flags, handler; +#else long handler, flags, restorer; +#endif uint64_t mask[20]; // larger than any known platform }; @@ -35,6 +39,10 @@ int main() { memset(&act, 0, sizeof(act)); __msan_poison(&oldact, sizeof(oldact)); __sanitizer_syscall_post_rt_sigaction(0, SIGUSR1, &act, &oldact, 5); +#if defined(__mips__) + assert(__msan_test_shadow(&oldact, sizeof(oldact)) == sizeof(long)*2 + 5); +#else assert(__msan_test_shadow(&oldact, sizeof(oldact)) == sizeof(long)*3 + 5); #endif +#endif } diff --git a/test/msan/allocator_mapping.cc b/test/msan/allocator_mapping.cc index f47d9a63e09f..533128f9a0f4 100644 --- a/test/msan/allocator_mapping.cc +++ b/test/msan/allocator_mapping.cc @@ -8,7 +8,7 @@ // This test only makes sense for the 64-bit allocator. The 32-bit allocator // does not have a fixed mapping. Exclude platforms that use the 32-bit // allocator. -// UNSUPPORTED: mips64,aarch64 +// UNSUPPORTED: target-is-mips64,target-is-mips64el,aarch64 #include <assert.h> #include <stdio.h> diff --git a/test/msan/backtrace.cc b/test/msan/backtrace.cc index 9cb883c5cf7d..cde4e8fc1c9e 100644 --- a/test/msan/backtrace.cc +++ b/test/msan/backtrace.cc @@ -15,7 +15,7 @@ void f() { if (!buf[i]) exit(1); char **s = backtrace_symbols(buf, sz); - assert(s > 0); + assert(s != 0); for (int i = 0; i < sz; ++i) printf("%d\n", (int)strlen(s[i])); } diff --git a/test/msan/chained_origin.cc b/test/msan/chained_origin.cc index ae72c10b6ac8..7cab15284d2b 100644 --- a/test/msan/chained_origin.cc +++ b/test/msan/chained_origin.cc @@ -1,21 +1,20 @@ // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-STACK < %t.out +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%short-stack --check-prefix=CHECK-STACK < %t.out // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DHEAP=1 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-HEAP < %t.out +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%short-stack --check-prefix=CHECK-HEAP < %t.out // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-STACK < %t.out +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%short-stack --check-prefix=CHECK-STACK < %t.out // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DHEAP=1 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-HEAP < %t.out - #include <stdio.h> volatile int x, y; @@ -48,19 +47,21 @@ int main(int argc, char *argv[]) { } // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value -// CHECK: {{#0 .* in main.*chained_origin.cc:47}} +// CHECK: {{#0 .* in main.*chained_origin.cc:}}[[@LINE-4]] // CHECK: Uninitialized value was stored to memory at -// CHECK: {{#0 .* in fn_h.*chained_origin.cc:35}} -// CHECK: {{#1 .* in main.*chained_origin.cc:46}} +// CHECK-FULL-STACK: {{#0 .* in fn_h.*chained_origin.cc:}}[[@LINE-19]] +// CHECK-FULL-STACK: {{#1 .* in main.*chained_origin.cc:}}[[@LINE-9]] +// CHECK-SHORT-STACK: {{#0 .* in fn_h.*chained_origin.cc:}}[[@LINE-21]] // CHECK: Uninitialized value was stored to memory at -// CHECK: {{#0 .* in fn_g.*chained_origin.cc:25}} -// CHECK: {{#1 .* in fn_f.*chained_origin.cc:30}} -// CHECK: {{#2 .* in main.*chained_origin.cc:45}} +// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin.cc:}}[[@LINE-34]] +// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin.cc:}}[[@LINE-30]] +// CHECK-FULL-STACK: {{#2 .* in main.*chained_origin.cc:}}[[@LINE-16]] +// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin.cc:}}[[@LINE-37]] // CHECK-STACK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main' -// CHECK-STACK: {{#0 .* in main.*chained_origin.cc:38}} +// CHECK-STACK: {{#0 .* in main.*chained_origin.cc:}}[[@LINE-27]] // CHECK-HEAP: Uninitialized value was created by a heap allocation -// CHECK-HEAP: {{#1 .* in main.*chained_origin.cc:40}} +// CHECK-HEAP: {{#1 .* in main.*chained_origin.cc:}}[[@LINE-28]] diff --git a/test/msan/chained_origin_limits.cc b/test/msan/chained_origin_limits.cc index 90fd09a86b29..9585889eb37a 100644 --- a/test/msan/chained_origin_limits.cc +++ b/test/msan/chained_origin_limits.cc @@ -10,7 +10,7 @@ // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out @@ -25,7 +25,7 @@ // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out @@ -41,7 +41,7 @@ // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out @@ -57,7 +57,7 @@ // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK --check-prefix=CHECK-%short-stack < %t.out // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out @@ -147,13 +147,21 @@ int main(void) { // CHECK2-NOT: Uninitialized value was stored to memory at // CHECK2: Uninitialized value was created +// For architectures with short stack all the stacks in the chain are same +// because the stack trace does not contain frames upto the functions fn1, fn2, +// fn3 from where the uninitialized stores actually originate. Since we report +// uninitialized value store once for each stack frame +// (origin_history_per_stack_limit = 1) we expect only one instance of +// "Uninitialized value was stored to memory at". + // CHECK-PER-STACK: WARNING: MemorySanitizer: use-of-uninitialized-value // CHECK-PER-STACK: Uninitialized value was stored to memory at -// CHECK-PER-STACK: in fn3 -// CHECK-PER-STACK: Uninitialized value was stored to memory at -// CHECK-PER-STACK: in fn2 -// CHECK-PER-STACK: Uninitialized value was stored to memory at -// CHECK-PER-STACK: in fn1 +// CHECK-SHORT-STACK: in __msan_memmove +// CHECK-FULL-STACK: in fn3 +// CHECK-FULL-STACK: Uninitialized value was stored to memory at +// CHECK-FULL-STACK: in fn2 +// CHECK-FULL-STACK: Uninitialized value was stored to memory at +// CHECK-FULL-STACK: in fn1 // CHECK-PER-STACK: Uninitialized value was created // CHECK-UNLIMITED: WARNING: MemorySanitizer: use-of-uninitialized-value diff --git a/test/msan/chained_origin_memcpy.cc b/test/msan/chained_origin_memcpy.cc index 3fe0b77a0614..bfe50dfec3f5 100644 --- a/test/msan/chained_origin_memcpy.cc +++ b/test/msan/chained_origin_memcpy.cc @@ -1,20 +1,19 @@ // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 < %t.out +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 < %t.out +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 < %t.out +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \ // RUN: not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 < %t.out - +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out #include <stdio.h> #include <string.h> @@ -47,15 +46,17 @@ int main(int argc, char *argv[]) { } // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value -// CHECK: {{#0 .* in main .*chained_origin_memcpy.cc:46}} +// CHECK: {{#0 .* in main .*chained_origin_memcpy.cc:}}[[@LINE-4]] // CHECK: Uninitialized value was stored to memory at -// CHECK: {{#1 .* in fn_h.*chained_origin_memcpy.cc:38}} +// CHECK-FULL-STACK: {{#1 .* in fn_h.*chained_origin_memcpy.cc:}}[[@LINE-15]] +// CHECK-SHORT-STACK: {{#0 .* in __msan_memcpy .*msan_interceptors.cc:}} // CHECK: Uninitialized value was stored to memory at -// CHECK: {{#0 .* in fn_g.*chained_origin_memcpy.cc:28}} -// CHECK: {{#1 .* in fn_f.*chained_origin_memcpy.cc:33}} +// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cc:}}[[@LINE-29]] +// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memcpy.cc:}}[[@LINE-25]] +// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cc:}}[[@LINE-31]] // CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main' // CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main' -// CHECK: {{#0 .* in main.*chained_origin_memcpy.cc:41}} +// CHECK: {{#0 .* in main.*chained_origin_memcpy.cc:}}[[@LINE-22]] diff --git a/test/msan/coverage-levels.cc b/test/msan/coverage-levels.cc index 710a69aff53a..b881cecac7e9 100644 --- a/test/msan/coverage-levels.cc +++ b/test/msan/coverage-levels.cc @@ -9,7 +9,7 @@ // RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN // RUN: %clangxx_msan -O1 -fsanitize-coverage=edge %s -o %t // RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN -// + volatile int sink; int main(int argc, char **argv) { int var; diff --git a/test/msan/fork.cc b/test/msan/fork.cc index 78a62d549ec3..e4dc5490887c 100644 --- a/test/msan/fork.cc +++ b/test/msan/fork.cc @@ -3,13 +3,16 @@ // and verify that origin reads do not deadlock in the child process. // RUN: %clangxx_msan -std=c++11 -fsanitize-memory-track-origins=2 -g -O3 %s -o %t -// RUN: MSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t |& FileCheck %s +// RUN: MSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t 2>&1 | FileCheck %s // Fun fact: if test output is redirected to a file (as opposed to // being piped directly to FileCheck), we may lose some "done"s due to // a kernel bug: // https://lkml.org/lkml/2014/2/17/324 +// Flaky on PPC64. +// UNSUPPORTED: powerpc64-target-arch +// UNSUPPORTED: powerpc64le-target-arch #include <pthread.h> #include <unistd.h> @@ -89,7 +92,7 @@ int main() { exit(0); } } - + for (int i = 0; i < kChildren; ++i) { pid_t p; while ((p = wait(NULL)) == -1) { } diff --git a/test/msan/getutent.cc b/test/msan/getutent.cc new file mode 100644 index 000000000000..36f9e1f1f7e3 --- /dev/null +++ b/test/msan/getutent.cc @@ -0,0 +1,17 @@ +// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t + +#include <utmp.h> +#include <utmpx.h> +#include <sanitizer/msan_interface.h> + +int main(void) { + setutent(); + while (struct utmp *ut = getutent()) + __msan_check_mem_is_initialized(ut, sizeof(*ut)); + endutent(); + + setutxent(); + while (struct utmpx *utx = getutxent()) + __msan_check_mem_is_initialized(utx, sizeof(*utx)); + endutxent(); +} diff --git a/test/msan/iconv.cc b/test/msan/iconv.cc index c2da938169b3..e5fbbf9241e7 100644 --- a/test/msan/iconv.cc +++ b/test/msan/iconv.cc @@ -1,5 +1,5 @@ // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t -// RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t && not %run %t |& FileCheck %s +// RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t && not %run %t 2>&1 | FileCheck %s #include <assert.h> #include <iconv.h> diff --git a/test/msan/lit.cfg b/test/msan/lit.cfg index d23ff31bc748..eb0ed43897ca 100644 --- a/test/msan/lit.cfg +++ b/test/msan/lit.cfg @@ -35,3 +35,11 @@ if config.host_os not in ['Linux']: if config.target_arch != 'aarch64': config.available_features.add('stable-runtime') + +# For mips64, mips64el we have forced store_context_size to 1 because these +# archs use slow unwinder which is not async signal safe. Therefore we only +# check the first frame since store_context size is 1. +if config.host_arch in ['mips64', 'mips64el']: + config.substitutions.append( ('CHECK-%short-stack', 'CHECK-SHORT-STACK')) +else: + config.substitutions.append( ('CHECK-%short-stack', 'CHECK-FULL-STACK')) diff --git a/test/msan/mmap.cc b/test/msan/mmap.cc index 27a8bb2d6eb5..65d8beeefe3a 100644 --- a/test/msan/mmap.cc +++ b/test/msan/mmap.cc @@ -19,7 +19,9 @@ bool AddrIsApp(void *p) { (addr >= 0x510000000000ULL && addr < 0x600000000000ULL) || (addr >= 0x700000000000ULL && addr < 0x800000000000ULL); #elif defined(__mips64) - return addr >= 0x00e000000000ULL; + return (addr >= 0x0000000000ULL && addr <= 0x0200000000ULL) || + (addr >= 0xa200000000ULL && addr <= 0xc000000000ULL) || + addr >= 0xe200000000ULL; #elif defined(__powerpc64__) return addr < 0x000100000000ULL || addr >= 0x300000000000ULL; #elif defined(__aarch64__) @@ -37,6 +39,12 @@ bool AddrIsApp(void *p) { {0x2E000000000ULL, 0x2F000000000ULL}, {0x3B000000000ULL, 0x3C000000000ULL}, {0x3F000000000ULL, 0x40000000000ULL}, + {0x0041000000000ULL, 0x0042000000000ULL}, + {0x0050000000000ULL, 0x0051000000000ULL}, + {0x0058000000000ULL, 0x0059000000000ULL}, + {0x0061000000000ULL, 0x0062000000000ULL}, + {0x0AAAAA0000000ULL, 0x0AAAB00000000ULL}, + {0x0FFFF00000000ULL, 0x1000000000000ULL}, }; const size_t mappingsSize = sizeof (mappings) / sizeof (mappings[0]); diff --git a/test/msan/msan_check_mem_is_initialized.cc b/test/msan/msan_check_mem_is_initialized.cc index 599cf2d7dd46..2991501921e9 100644 --- a/test/msan/msan_check_mem_is_initialized.cc +++ b/test/msan/msan_check_mem_is_initialized.cc @@ -1,5 +1,5 @@ // RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t -// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK +// RUN: not %run %t 2>&1 | FileCheck %s // RUN: MSAN_OPTIONS=verbosity=1 not %run %t 2>&1 | \ // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-VERBOSE diff --git a/test/msan/msan_copy_shadow.cc b/test/msan/msan_copy_shadow.cc index a1c6347ff4e3..19da73810509 100644 --- a/test/msan/msan_copy_shadow.cc +++ b/test/msan/msan_copy_shadow.cc @@ -1,7 +1,7 @@ // Test that __msan_copy_shadow copies shadow, updates origin and does not touch // the application memory. // RUN: %clangxx_msan -fsanitize-memory-track-origins=0 -O0 %s -o %t && not %run %t 2>&1 -// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-%short-stack %s #include <assert.h> #include <string.h> @@ -28,7 +28,8 @@ int main() { // CHECK: use-of-uninitialized-value // CHECK: {{in main.*msan_copy_shadow.cc:}}[[@LINE-2]] // CHECK: Uninitialized value was stored to memory at - // CHECK: {{in main.*msan_copy_shadow.cc:}}[[@LINE-8]] + // CHECK-FULL-STACK: {{in main.*msan_copy_shadow.cc:}}[[@LINE-8]] + // CHECK-SHORT-STACK: {{in __msan_copy_shadow .*msan_interceptors.cc:}} // CHECK: Uninitialized value was created by a heap allocation - // CHECK: {{in main.*msan_copy_shadow.cc:}}[[@LINE-22]] + // CHECK: {{in main.*msan_copy_shadow.cc:}}[[@LINE-23]] } diff --git a/test/msan/print_stats.cc b/test/msan/print_stats.cc index 39af504179d6..5b46d4ebbff2 100644 --- a/test/msan/print_stats.cc +++ b/test/msan/print_stats.cc @@ -1,22 +1,22 @@ // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g %s -o %t // RUN: %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s // RUN: MSAN_OPTIONS=print_stats=1 %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s // RUN: MSAN_OPTIONS=print_stats=1,atexit=1 %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-STATS %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS %s // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g -DPOSITIVE=1 %s -o %t // RUN: not %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s // RUN: MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-STATS %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS %s -// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g -DPOSITIVE=1 -mllvm -msan-keep-going=1 %s -o %t +// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -fsanitize-recover=memory -g -DPOSITIVE=1 %s -o %t // RUN: not %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS --check-prefix=CHECK-KEEPGOING %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS,CHECK-RECOVER %s // RUN: MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-STATS --check-prefix=CHECK-KEEPGOING %s +// RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS,CHECK-RECOVER %s #include <stdio.h> int main(int argc, char **argv) { @@ -42,4 +42,4 @@ int main(int argc, char **argv) { // CHECK-NOSTATS-NOT: Unique origin histories: // CHECK-NOSTATS-NOT: History depot allocated bytes: -// CHECK-KEEPGOING: MemorySanitizer: 1 warnings reported. +// CHECK-RECOVER: MemorySanitizer: 1 warnings reported. diff --git a/test/msan/realloc-large-origin.cc b/test/msan/realloc-large-origin.cc index ce25ad8c47fd..6893c1d17c48 100644 --- a/test/msan/realloc-large-origin.cc +++ b/test/msan/realloc-large-origin.cc @@ -1,7 +1,7 @@ // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && not %run %t >%t.out 2>&1 -// RUN: FileCheck %s < %t.out +// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-%short-stack %s < %t.out // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O2 %s -o %t && not %run %t >%t.out 2>&1 -// RUN: FileCheck %s < %t.out +// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-%short-stack %s < %t.out // This is a regression test: there used to be broken "stored to memory at" // stacks with @@ -21,10 +21,11 @@ int main(int argc, char **argv) { // CHECK: {{#0 0x.* in main .*realloc-large-origin.cc:}}[[@LINE-3]] // CHECK: Uninitialized value was stored to memory at -// CHECK: {{#0 0x.* in .*realloc}} -// CHECK: {{#1 0x.* in main .*realloc-large-origin.cc:}}[[@LINE-10]] +// CHECK-FULL-STACK: {{#0 0x.* in .*realloc}} +// CHECK-FULL-STACK: {{#1 0x.* in main .*realloc-large-origin.cc:}}[[@LINE-10]] +// CHECK-SHORT-STACK: {{#0 0x.* in .*realloc}} // CHECK: Uninitialized value was created by a heap allocation // CHECK: {{#0 0x.* in .*malloc}} -// CHECK: {{#1 0x.* in main .*realloc-large-origin.cc:}}[[@LINE-15]] +// CHECK: {{#1 0x.* in main .*realloc-large-origin.cc:}}[[@LINE-16]] } diff --git a/test/msan/keep-going-dso.cc b/test/msan/recover-dso.cc index f32a513ea9e7..2f4225659dd4 100644 --- a/test/msan/keep-going-dso.cc +++ b/test/msan/recover-dso.cc @@ -1,22 +1,28 @@ // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 // FileCheck %s <%t.out // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 -// FileCheck %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out - -// Test how -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going affect reports +// Test how -fsanitize-recover=memory and MSAN_OPTIONS=keep_going affect reports // from interceptors. -// -mllvm -msan-keep-going provides the default value of keep_going flag, but is +// -fsanitize-recover=memory provides the default value of keep_going flag, but is // always overwritten by MSAN_OPTIONS +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 +// FileCheck %s <%t.out +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out + +// Test how legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going affect +// reports from interceptors. + +// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -28,6 +34,6 @@ int main(int argc, char **argv) { exit(0); fprintf(stderr, "Done\n"); // CHECK-NOT: Done - // CHECK-KEEP-GOING: Done + // CHECK-RECOVER: Done return 0; } diff --git a/test/msan/keep-going.cc b/test/msan/recover.cc index 57729756357d..cb9916ef4755 100644 --- a/test/msan/keep-going.cc +++ b/test/msan/recover.cc @@ -5,20 +5,27 @@ // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 // FileCheck %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 +// Test behavior of -fsanitize-recover=memory and MSAN_OPTIONS=keep_going. +// -fsanitize-recover=memory provides the default value of keep_going flag; value +// of 1 can be overwritten by MSAN_OPTIONS, value of 0 can not. + +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 // FileCheck %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1 +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1 // FileCheck %s <%t.out -// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1 -// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out +// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out -// Test behaviour of -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going. -// -mllvm -msan-keep-going provides the default value of keep_going flag; value -// of 1 can be overwritten by MSAN_OPTIONS, value of 0 can not. +// Basic test of legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going. + +// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1 +// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out +// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 +// FileCheck %s <%t.out #include <stdio.h> #include <stdlib.h> @@ -29,6 +36,6 @@ int main(int argc, char **argv) { exit(0); fprintf(stderr, "Done\n"); // CHECK-NOT: Done - // CHECK-KEEP-GOING: Done + // CHECK-RECOVER: Done return 0; } diff --git a/test/msan/strlen_of_shadow.cc b/test/msan/strlen_of_shadow.cc index 3066dd5b61ae..b9cf5f065d2d 100644 --- a/test/msan/strlen_of_shadow.cc +++ b/test/msan/strlen_of_shadow.cc @@ -14,7 +14,7 @@ const char *mem_to_shadow(const char *p) { #if defined(__x86_64__) return (char *)((uintptr_t)p ^ 0x500000000000ULL); #elif defined (__mips64) - return (char *)((uintptr_t)p & ~0x4000000000ULL); + return (char *)((uintptr_t)p ^ 0x8000000000ULL); #elif defined(__powerpc64__) #define LINEARIZE_MEM(mem) \ (((uintptr_t)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL) |