summaryrefslogtreecommitdiff
path: root/test/msan
diff options
context:
space:
mode:
Diffstat (limited to 'test/msan')
-rw-r--r--test/msan/Linux/reexec_unlimited_stack.cc23
-rw-r--r--test/msan/Linux/sunrpc.cc2
-rw-r--r--test/msan/Linux/sunrpc_bytes.cc2
-rw-r--r--test/msan/Linux/sunrpc_string.cc2
-rw-r--r--test/msan/chained_origin_with_signals.cc3
-rw-r--r--test/msan/dtls_test.c8
-rw-r--r--test/msan/fork.cc3
-rw-r--r--test/msan/ioctl_custom.cc3
-rw-r--r--test/msan/lit.cfg8
-rw-r--r--test/msan/pthread_getname_np.cc6
-rw-r--r--test/msan/signal_stress_test.cc3
-rw-r--r--test/msan/strndup.cc2
-rw-r--r--test/msan/tls_reuse.cc1
-rw-r--r--test/msan/vararg.cc60
14 files changed, 122 insertions, 4 deletions
diff --git a/test/msan/Linux/reexec_unlimited_stack.cc b/test/msan/Linux/reexec_unlimited_stack.cc
new file mode 100644
index 000000000000..61492ec34533
--- /dev/null
+++ b/test/msan/Linux/reexec_unlimited_stack.cc
@@ -0,0 +1,23 @@
+// MSAN re-execs on unlimited stacks. We use that to verify ReExec() uses the
+// right path.
+// RUN: %clangxx_msan -O0 %s -o %t && ulimit -s unlimited && %run %t | FileCheck %s
+
+#include <stdio.h>
+
+#if !defined(__GLIBC_PREREQ)
+#define __GLIBC_PREREQ(a, b) 0
+#endif
+
+#if __GLIBC_PREREQ(2, 16)
+#include <sys/auxv.h>
+#endif
+
+int main() {
+#if __GLIBC_PREREQ(2, 16)
+ // Make sure AT_EXECFN didn't get overwritten by re-exec.
+ puts(reinterpret_cast<const char *>(getauxval(AT_EXECFN)));
+#else
+ puts("No getauxval");
+#endif
+ // CHECK-NOT: /proc/self/exe
+}
diff --git a/test/msan/Linux/sunrpc.cc b/test/msan/Linux/sunrpc.cc
index c92ad632c095..edf49c2a5cee 100644
--- a/test/msan/Linux/sunrpc.cc
+++ b/test/msan/Linux/sunrpc.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
// RUN: %clangxx_msan -g -O0 -DTYPE=int -DFN=xdr_int %s -o %t && \
// RUN: %run %t 2>&1
// RUN: %clangxx_msan -g -O0 -DTYPE=int -DFN=xdr_int -DUNINIT=1 %s -o %t && \
diff --git a/test/msan/Linux/sunrpc_bytes.cc b/test/msan/Linux/sunrpc_bytes.cc
index 477637af2b63..7eb47e178492 100644
--- a/test/msan/Linux/sunrpc_bytes.cc
+++ b/test/msan/Linux/sunrpc_bytes.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
// RUN: %clangxx_msan -g -O0 %s -o %t && \
// RUN: %run %t 2>&1
// RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
diff --git a/test/msan/Linux/sunrpc_string.cc b/test/msan/Linux/sunrpc_string.cc
index 350222f5cc1e..723b85592261 100644
--- a/test/msan/Linux/sunrpc_string.cc
+++ b/test/msan/Linux/sunrpc_string.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
// RUN: %clangxx_msan -g -O0 %s -o %t && \
// RUN: %run %t 2>&1
// RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
diff --git a/test/msan/chained_origin_with_signals.cc b/test/msan/chained_origin_with_signals.cc
index 43dbdcca76a9..9c071569a2ba 100644
--- a/test/msan/chained_origin_with_signals.cc
+++ b/test/msan/chained_origin_with_signals.cc
@@ -10,6 +10,9 @@
// RUN: not %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out
+// Reported deadly signal due to stack-overflow
+// XFAIL: netbsd
+
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
diff --git a/test/msan/dtls_test.c b/test/msan/dtls_test.c
index b9021e0da1af..bc1fe609a850 100644
--- a/test/msan/dtls_test.c
+++ b/test/msan/dtls_test.c
@@ -8,6 +8,14 @@
XFAIL: FreeBSD
UNSUPPORTED: powerpc
+
+ // Reports use-of-uninitialized-value, not analyzed
+ XFAIL: netbsd
+
+ // This is known to be broken with glibc-2.27+
+ // https://bugs.llvm.org/show_bug.cgi?id=37804
+ XFAIL: glibc-2.27
+
*/
#ifndef BUILD_SO
diff --git a/test/msan/fork.cc b/test/msan/fork.cc
index e4dc5490887c..87d71f87efe6 100644
--- a/test/msan/fork.cc
+++ b/test/msan/fork.cc
@@ -14,6 +14,9 @@
// UNSUPPORTED: powerpc64-target-arch
// UNSUPPORTED: powerpc64le-target-arch
+// Sometimes hangs
+// UNSUPPORTED: netbsd
+
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/test/msan/ioctl_custom.cc b/test/msan/ioctl_custom.cc
index eaab63384582..794f34535358 100644
--- a/test/msan/ioctl_custom.cc
+++ b/test/msan/ioctl_custom.cc
@@ -4,6 +4,9 @@
// RUN: %clangxx_msan -DPOSITIVE -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_msan -DPOSITIVE -O3 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// Reports different report (not analyzed)
+// XFAIL: netbsd
+
#include <assert.h>
#include <stdlib.h>
#include <net/if.h>
diff --git a/test/msan/lit.cfg b/test/msan/lit.cfg
index 550d04d0812b..e08673d5cfea 100644
--- a/test/msan/lit.cfg
+++ b/test/msan/lit.cfg
@@ -17,14 +17,20 @@ clang_msan_cflags = (["-fsanitize=memory",
config.debug_info_flags)
# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
if config.host_os == 'FreeBSD':
- clang_msan_cflags += ["-lexecinfo"]
+ clang_msan_cflags += ["-lexecinfo", "-fPIC"]
clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags
+# Flags for KMSAN invocation. This is C-only, we're not interested in C++.
+clang_kmsan_cflags = (["-fsanitize=kernel-memory"] +
+ [config.target_cflags] +
+ config.debug_info_flags)
+
def build_invocation(compile_flags):
return " " + " ".join([config.clang] + compile_flags) + " "
config.substitutions.append( ("%clang_msan ", build_invocation(clang_msan_cflags)) )
config.substitutions.append( ("%clangxx_msan ", build_invocation(clang_msan_cxxflags)) )
+config.substitutions.append( ("%clang_kmsan ", build_invocation(clang_kmsan_cflags)) )
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
diff --git a/test/msan/pthread_getname_np.cc b/test/msan/pthread_getname_np.cc
index e19b652a73c9..4827b3a00643 100644
--- a/test/msan/pthread_getname_np.cc
+++ b/test/msan/pthread_getname_np.cc
@@ -1,7 +1,7 @@
// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t
// The main goal is getting the pthread name back and
// FreeBSD based do not support this feature
-// UNSUPPORTED: android, netbsd, freebsd
+// UNSUPPORTED: android, freebsd
// Regression test for a deadlock in pthread_getattr_np
@@ -32,7 +32,11 @@ int main(void) {
assert(!res);
const char *kMyThreadName = "my-thread-name";
+#if defined(__NetBSD__)
+ res = pthread_setname_np(t, "%s", (void *)kMyThreadName);
+#else
res = pthread_setname_np(t, kMyThreadName);
+#endif
assert(!res);
char buf[100];
diff --git a/test/msan/signal_stress_test.cc b/test/msan/signal_stress_test.cc
index 5bc6f59213b1..dfbc580faf2c 100644
--- a/test/msan/signal_stress_test.cc
+++ b/test/msan/signal_stress_test.cc
@@ -2,6 +2,9 @@
//
// Test that va_arg shadow from a signal handler does not leak outside.
+// Reported deadly signal due to stack-overflow
+// XFAIL: netbsd
+
#include <signal.h>
#include <stdarg.h>
#include <sanitizer/msan_interface.h>
diff --git a/test/msan/strndup.cc b/test/msan/strndup.cc
index d4b9af1a9a6e..07bdd9f8f5fb 100644
--- a/test/msan/strndup.cc
+++ b/test/msan/strndup.cc
@@ -4,7 +4,7 @@
// When built as C on Linux, strndup is transformed to __strndup.
// RUN: %clangxx_msan -O3 -xc %s -o %t && not %run %t 2>&1 | FileCheck --check-prefix=ON %s
-// UNSUPPORTED: win32
+// UNSUPPORTED: windows-msvc
#include <assert.h>
#include <stdlib.h>
diff --git a/test/msan/tls_reuse.cc b/test/msan/tls_reuse.cc
index 9c2ee975cb57..78a328fa3ce0 100644
--- a/test/msan/tls_reuse.cc
+++ b/test/msan/tls_reuse.cc
@@ -1,7 +1,6 @@
// RUN: %clangxx_msan -O0 %s -o %t && %run %t
// Check that when TLS block is reused between threads, its shadow is cleaned.
-// XFAIL: freebsd
#include <pthread.h>
#include <stdio.h>
diff --git a/test/msan/vararg.cc b/test/msan/vararg.cc
new file mode 100644
index 000000000000..e1a7b1266165
--- /dev/null
+++ b/test/msan/vararg.cc
@@ -0,0 +1,60 @@
+// RUN: %clangxx_msan -fsanitize-memory-track-origins=0 -O3 %s -o %t && \
+// RUN: not %run %t va_arg_tls >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK < %t.out
+
+// RUN: %clangxx_msan -fsanitize-memory-track-origins=0 -O3 %s -o %t && \
+// RUN: not %run %t overflow >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK < %t.out
+
+// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
+// RUN: not %run %t va_arg_tls >%t.out 2>&1
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN < %t.out
+
+// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
+// RUN: not %run %t overflow >%t.out 2>&1
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN < %t.out
+
+// Check that shadow and origin are passed through va_args.
+
+// Copying origins on AArch64, MIPS and PowerPC isn't supported yet.
+// XFAIL: aarch64
+// XFAIL: mips
+// XFAIL: powerpc64
+
+#include <stdarg.h>
+#include <string.h>
+
+__attribute__((noinline))
+int sum(int n, ...) {
+ va_list args;
+ int i, sum = 0, arg;
+ volatile int temp;
+ va_start(args, n);
+ for (i = 0; i < n; i++) {
+ arg = va_arg(args, int);
+ sum += arg;
+ }
+ va_end(args);
+ return sum;
+}
+
+int main(int argc, char *argv[]) {
+ volatile int uninit;
+ volatile int a = 1, b = 2;
+ if (argc == 2) {
+ // Shadow/origin will be passed via va_arg_tls/va_arg_origin_tls.
+ if (strcmp(argv[1], "va_arg_tls") == 0) {
+ return sum(3, uninit, a, b);
+ }
+ // Shadow/origin of |uninit| will be passed via overflow area.
+ if (strcmp(argv[1], "overflow") == 0) {
+ return sum(7,
+ a, a, a, a, a, a, uninit
+ );
+ }
+ }
+ return 0;
+}
+
+// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
+// CHECK-ORIGIN: Uninitialized value was created by an allocation of 'uninit' in the stack frame of function 'main'