summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2018-10-11 01:05:18 +0000
committerKostya Serebryany <kcc@google.com>2018-10-11 01:05:18 +0000
commit3d3d9d69fb6488f733629ecbc59fc0a74fb4de38 (patch)
tree8183fb2556c931f3eb55fed56e26fa8a7dd364a4
parenta535e0543f44a4c453e8f96624dfe00b68b6568d (diff)
downloadbcm5719-llvm-3d3d9d69fb6488f733629ecbc59fc0a74fb4de38.tar.gz
bcm5719-llvm-3d3d9d69fb6488f733629ecbc59fc0a74fb4de38.zip
[hwasan] extend the stack-uar test
llvm-svn: 344213
-rw-r--r--compiler-rt/test/hwasan/TestCases/stack-uar.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/compiler-rt/test/hwasan/TestCases/stack-uar.c b/compiler-rt/test/hwasan/TestCases/stack-uar.c
index 2c59b1785d2..8af56a9711f 100644
--- a/compiler-rt/test/hwasan/TestCases/stack-uar.c
+++ b/compiler-rt/test/hwasan/TestCases/stack-uar.c
@@ -1,23 +1,37 @@
+// Tests use-after-return detection and reporting.
// RUN: %clang_hwasan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// REQUIRES: stable-runtime
-#include <stdlib.h>
-#include <sanitizer/hwasan_interface.h>
+void USE(void *x) { // pretend_to_do_something(void *x)
+ __asm__ __volatile__("" : : "r" (x) : "memory");
+}
__attribute__((noinline))
-char *f() {
+char *buggy() {
char z[0x1000];
char *volatile p = z;
return p;
}
+__attribute__((noinline)) void Unrelated1() { int A[2]; USE(&A[0]); }
+__attribute__((noinline)) void Unrelated2() { int BB[3]; USE(&BB[0]); }
+__attribute__((noinline)) void Unrelated3() { int CCC[4]; USE(&CCC[0]); }
+
int main() {
- return *f();
+ char *p = buggy();
+ Unrelated1();
+ Unrelated2();
+ Unrelated3();
+ return *p;
// CHECK: READ of size 1 at
- // CHECK: #0 {{.*}} in main{{.*}}stack-uar.c:16
-
+ // CHECK: #0 {{.*}} in main{{.*}}stack-uar.c:[[@LINE-2]]
// CHECK: is located in stack of thread
+ // CHECK: Previosly allocated frames:
+ // CHECK: Unrelated3
+ // CHECK: Unrelated2
+ // CHECK: Unrelated1
+ // CHECK: buggy
// CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
}
OpenPOWER on IntegriCloud