diff options
| -rw-r--r-- | compiler-rt/lib/asan/asan_fake_stack.h | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/lit_tests/Linux/heavy_uar_test.cc | 11 | 
2 files changed, 8 insertions, 5 deletions
diff --git a/compiler-rt/lib/asan/asan_fake_stack.h b/compiler-rt/lib/asan/asan_fake_stack.h index c0cb5191ab4..308b4c57183 100644 --- a/compiler-rt/lib/asan/asan_fake_stack.h +++ b/compiler-rt/lib/asan/asan_fake_stack.h @@ -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_; diff --git a/compiler-rt/lib/asan/lit_tests/Linux/heavy_uar_test.cc b/compiler-rt/lib/asan/lit_tests/Linux/heavy_uar_test.cc index c5ffb730234..bd75e97d0b5 100644 --- a/compiler-rt/lib/asan/lit_tests/Linux/heavy_uar_test.cc +++ b/compiler-rt/lib/asan/lit_tests/Linux/heavy_uar_test.cc @@ -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 depth) {  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  | 

