[compiler-rt] r179286 - [asan] make heavy_uar_test a bit more heavy and fix he fake stack to pass this test

Kostya Serebryany kcc at google.com
Thu Apr 11 07:07:02 PDT 2013


Author: kcc
Date: Thu Apr 11 09:07:02 2013
New Revision: 179286

URL: http://llvm.org/viewvc/llvm-project?rev=179286&view=rev
Log:
[asan] make heavy_uar_test a bit more heavy and fix he fake stack to pass this test

Modified:
    compiler-rt/trunk/lib/asan/asan_fake_stack.h
    compiler-rt/trunk/lib/asan/lit_tests/Linux/heavy_uar_test.cc

Modified: compiler-rt/trunk/lib/asan/asan_fake_stack.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_fake_stack.h?rev=179286&r1=179285&r2=179286&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_fake_stack.h (original)
+++ compiler-rt/trunk/lib/asan/asan_fake_stack.h Thu Apr 11 09:07:02 2013
@@ -53,7 +53,7 @@ class FakeFrameLifo {
   FakeFrame *top() {
     if (n_frames_ == 0)
       return 0;
-    return frames_[n_frames_];
+    return frames_[n_frames_ - 1];
   }
  private:
   uptr n_frames_;

Modified: compiler-rt/trunk/lib/asan/lit_tests/Linux/heavy_uar_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/Linux/heavy_uar_test.cc?rev=179286&r1=179285&r2=179286&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/Linux/heavy_uar_test.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/Linux/heavy_uar_test.cc Thu Apr 11 09:07:02 2013
@@ -7,6 +7,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 __attribute__((noinline))
 inline char *pretend_to_do_something(char *x) {
@@ -24,7 +25,7 @@ char *LeakStack() {
 __attribute__((noinline))
 void RecuriveFunctionWithStackFrame(int depth) {
   if (depth <= 0) return;
-  char x[1000];
+  char x[1024];
   memset(x, 0, sizeof(x));
   pretend_to_do_something(x);
   RecuriveFunctionWithStackFrame(depth - 1);
@@ -33,9 +34,11 @@ void RecuriveFunctionWithStackFrame(int
 
 int main(int argc, char **argv) {
   char *stale_stack = LeakStack();
-  RecuriveFunctionWithStackFrame(10);
-  RecuriveFunctionWithStackFrame(20);
-  RecuriveFunctionWithStackFrame(30);
+  int n_iter = argc >= 2 ? atoi(argv[1]) : 1000;
+  int depth  = argc >= 3 ? atoi(argv[2]) : 1000;
+  for (int i = 0; i < n_iter; i++) {
+    RecuriveFunctionWithStackFrame(depth);
+  }
   stale_stack[100]++;
   // CHECK: ERROR: AddressSanitizer: stack-use-after-return on address
   // CHECK: is located in stack of thread T0 at offset 132 in frame





More information about the llvm-commits mailing list