summaryrefslogtreecommitdiff
path: root/test/lsan/TestCases/use_poisoned_asan.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-08-05 07:04:42 +0000
committerFangrui Song <maskray@google.com>2019-08-05 07:04:42 +0000
commit73f86c7eb9f8f3987c5dcf31c70c6fd871eb44cd (patch)
tree196312bced33cb72afd6e16c24c8a81a6d018553 /test/lsan/TestCases/use_poisoned_asan.cpp
parent1b40f846e2b6980c42823483488e6d690ac5b22e (diff)
downloadcompiler-rt-73f86c7eb9f8f3987c5dcf31c70c6fd871eb44cd.tar.gz
compiler-rt: Rename .cc file in test/lsan to .cpp
Like r367463, but for test/lsan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/lsan/TestCases/use_poisoned_asan.cpp')
-rw-r--r--test/lsan/TestCases/use_poisoned_asan.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lsan/TestCases/use_poisoned_asan.cpp b/test/lsan/TestCases/use_poisoned_asan.cpp
new file mode 100644
index 000000000..780792e95
--- /dev/null
+++ b/test/lsan/TestCases/use_poisoned_asan.cpp
@@ -0,0 +1,26 @@
+// ASan-poisoned memory should be ignored if use_poisoned is false.
+// REQUIRES: asan
+// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
+// RUN: %clangxx_lsan %s -o %t
+// RUN: %env_lsan_opts=$LSAN_BASE:"use_poisoned=0" not %run %t 2>&1 | FileCheck %s
+// RUN: %env_lsan_opts=$LSAN_BASE:"use_poisoned=1" %run %t 2>&1
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sanitizer/asan_interface.h>
+#include <assert.h>
+#include "sanitizer_common/print_address.h"
+
+void **p;
+
+int main() {
+ p = new void *;
+ *p = malloc(1337);
+ print_address("Test alloc: ", 1, *p);
+ __asan_poison_memory_region(p, sizeof(*p));
+ return 0;
+}
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
+// CHECK: LeakSanitizer: detected memory leaks
+// CHECK: [[ADDR]] (1337 bytes)
+// CHECK: SUMMARY: AddressSanitizer: