[compiler-rt] r344213 - [hwasan] extend the stack-uar test

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 18:05:18 PDT 2018


Author: kcc
Date: Wed Oct 10 18:05:18 2018
New Revision: 344213

URL: http://llvm.org/viewvc/llvm-project?rev=344213&view=rev
Log:
[hwasan] extend the stack-uar test

Modified:
    compiler-rt/trunk/test/hwasan/TestCases/stack-uar.c

Modified: compiler-rt/trunk/test/hwasan/TestCases/stack-uar.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/hwasan/TestCases/stack-uar.c?rev=344213&r1=344212&r2=344213&view=diff
==============================================================================
--- compiler-rt/trunk/test/hwasan/TestCases/stack-uar.c (original)
+++ compiler-rt/trunk/test/hwasan/TestCases/stack-uar.c Wed Oct 10 18:05:18 2018
@@ -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
 }




More information about the llvm-commits mailing list