summaryrefslogtreecommitdiff
path: root/test/msan
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2018-02-26 18:27:24 +0000
committerAlex Shlyapnikov <alekseys@google.com>2018-02-26 18:27:24 +0000
commite89072679fec4d71608008233f20e756812704db (patch)
treeef8e434f9d695d8ccc0b2f4ca2ff8e6410ed8b1c /test/msan
parentfbef9e077c6fab0a50b1ce91d7264a271b208ef1 (diff)
[MSan] Print current stack on CHECK violation
Summary: Print current stack on CHECK violation to aid debugging and match other sanitizers functionality. Reviewers: eugenis Subscribers: delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D43692 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@326105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/msan')
-rw-r--r--test/msan/check-handler.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/msan/check-handler.cc b/test/msan/check-handler.cc
new file mode 100644
index 000000000..4721f8c30
--- /dev/null
+++ b/test/msan/check-handler.cc
@@ -0,0 +1,16 @@
+// RUN: %clangxx_msan -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+// Verify that CHECK handler prints a stack on CHECK fail.
+
+#include <stdlib.h>
+
+int main(void) {
+ // Allocate chunk from the secondary allocator to trigger CHECK(IsALigned())
+ // in its free() path.
+ void *p = malloc(8 << 20);
+ free(reinterpret_cast<char*>(p) + 1);
+ // CHECK: MemorySanitizer: bad pointer
+ // CHECK: MemorySanitizer CHECK failed
+ // CHECK: #0
+ return 0;
+}