summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test
diff options
context:
space:
mode:
authorEvgenii Stepanov <eugenis@google.com>2019-12-20 12:07:04 -0800
committerEvgenii Stepanov <eugenis@google.com>2019-12-20 12:41:57 -0800
commitddf897fc80499ece298bc33201db6b697d2af50e (patch)
tree3ec5019759a4a0e37ddc0f224a1653d9cb117afd /compiler-rt/test
parent59878ec8092bef656a71d22261fd3b70651e8318 (diff)
downloadbcm5719-llvm-ddf897fc80499ece298bc33201db6b697d2af50e.tar.gz
bcm5719-llvm-ddf897fc80499ece298bc33201db6b697d2af50e.zip
[msan] Check qsort input.
Summary: Qsort interceptor suppresses all checks by unpoisoning the data in the wrapper of a comparator function, and then unpoisoning the output array as well. This change adds an explicit run of the comparator on all elements of the input array to catch any sanitizer bugs. Reviewers: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71780
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/msan/qsort.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler-rt/test/msan/qsort.cpp b/compiler-rt/test/msan/qsort.cpp
index eb869701186..cf754012b22 100644
--- a/compiler-rt/test/msan/qsort.cpp
+++ b/compiler-rt/test/msan/qsort.cpp
@@ -1,4 +1,5 @@
// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -DPOISON -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
#include <assert.h>
#include <errno.h>
@@ -65,6 +66,10 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < kSize1; ++i)
p[i] = i * 2 + (i % 3 - 1) * 3;
poison_stack_and_param();
+#ifdef POISON
+ __msan_poison(p + 1, sizeof(long));
+ // CHECK: Uninitialized bytes in __msan_check_mem_is_initialized at offset 0 inside [{{.*}}, 8)
+#endif
qsort(p, kSize1, sizeof(long), compar1);
__msan_check_mem_is_initialized(p, sizeof(long) * kSize1);
assert(seen2);
OpenPOWER on IntegriCloud