summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/msan/memcmp_test.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-07-29 23:53:08 +0000
committerKostya Serebryany <kcc@google.com>2015-07-29 23:53:08 +0000
commitc69bf1b4c02a4e6a3ce93ca8c9bfc11567c42d8a (patch)
tree56ebb0cc94af9913d5c19b4d75e84e155d6515c3 /compiler-rt/test/msan/memcmp_test.cc
parent1993dc8b15d4d8835e773499240fad2da1152fb2 (diff)
downloadbcm5719-llvm-c69bf1b4c02a4e6a3ce93ca8c9bfc11567c42d8a.tar.gz
bcm5719-llvm-c69bf1b4c02a4e6a3ce93ca8c9bfc11567c42d8a.zip
[asan,tsan,msan] move the memcmp interceptor from asan/tsan to sanitizer_common. This may potentially lead to more reports from msan as it now sees the reads inside memcmp. To disable, use the flag intercept_memcmp=0. Likewise, it may potentially cause new races to appear due to more strict memcmp checking (flag strict_memcmp=1)
llvm-svn: 243595
Diffstat (limited to 'compiler-rt/test/msan/memcmp_test.cc')
-rw-r--r--compiler-rt/test/msan/memcmp_test.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler-rt/test/msan/memcmp_test.cc b/compiler-rt/test/msan/memcmp_test.cc
new file mode 100644
index 00000000000..95228eb127d
--- /dev/null
+++ b/compiler-rt/test/msan/memcmp_test.cc
@@ -0,0 +1,15 @@
+// RUN: %clangxx_msan -O0 -g %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: MSAN_OPTIONS=intercept_memcmp=0 %run %t
+
+#include <string.h>
+int main(int argc, char **argv) {
+ char a1[4];
+ char a2[4];
+ for (int i = 0; i < argc * 3; i++)
+ a2[i] = a1[i] = i;
+ int res = memcmp(a1, a2, 4);
+ return res;
+ // CHECK: Uninitialized bytes in __interceptor_memcmp at offset 3
+ // CHECK: MemorySanitizer: use-of-uninitialized-value
+}
OpenPOWER on IntegriCloud