[compiler-rt] r189929 - [asan] make use-after-return handle very deep recursion; fixes 483.xalancbmk in UAR mode

Kostya Serebryany kcc at google.com
Wed Sep 4 03:59:32 PDT 2013


Author: kcc
Date: Wed Sep  4 05:59:32 2013
New Revision: 189929

URL: http://llvm.org/viewvc/llvm-project?rev=189929&view=rev
Log:
[asan] make use-after-return handle very deep recursion; fixes 483.xalancbmk in UAR mode

Added:
    compiler-rt/trunk/lib/asan/lit_tests/TestCases/deep_call_stack.cc
Modified:
    compiler-rt/trunk/lib/asan/asan_fake_stack.cc
    compiler-rt/trunk/lib/asan/asan_fake_stack.h

Modified: compiler-rt/trunk/lib/asan/asan_fake_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_fake_stack.cc?rev=189929&r1=189928&r2=189929&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_fake_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_fake_stack.cc Wed Sep  4 05:59:32 2013
@@ -102,10 +102,12 @@ void FakeStack::AllocateOneSizeClass(upt
   CHECK(ClassMmapSize(size_class) >= GetPageSizeCached());
   uptr new_mem = (uptr)MmapOrDie(
       ClassMmapSize(size_class), __FUNCTION__);
-  // Printf("T%d new_mem[%zu]: %p-%p mmap %zu\n",
-  //       GetCurrentThread()->tid(),
-  //       size_class, new_mem, new_mem + ClassMmapSize(size_class),
-  //       ClassMmapSize(size_class));
+  if (0) {
+    Printf("T%d new_mem[%zu]: %p-%p mmap %zu\n",
+           GetCurrentThread()->tid(),
+           size_class, new_mem, new_mem + ClassMmapSize(size_class),
+           ClassMmapSize(size_class));
+  }
   uptr i;
   uptr size = ClassSize(size_class);
   for (i = 0; i + size <= ClassMmapSize(size_class); i += size) {

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=189929&r1=189928&r2=189929&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_fake_stack.h (original)
+++ compiler-rt/trunk/lib/asan/asan_fake_stack.h Wed Sep  4 05:59:32 2013
@@ -81,12 +81,12 @@ class FakeStack {
   uptr StackSize() const { return stack_size_; }
 
  private:
-  static const uptr kMinStackFrameSizeLog = 9;  // Min frame is 512B.
+  static const uptr kMinStackFrameSizeLog = 7;  // Min frame is 128B.
   static const uptr kMaxStackFrameSizeLog = 16;  // Max stack frame is 64K.
   static const uptr kMaxStackMallocSize = 1 << kMaxStackFrameSizeLog;
   static const uptr kNumberOfSizeClasses =
       kMaxStackFrameSizeLog - kMinStackFrameSizeLog + 1;
-  static const uptr kMaxRecursionDepth = 15000;
+  static const uptr kMaxRecursionDepth = 60000;
 
   bool AddrIsInSizeClass(uptr addr, uptr size_class);
 
@@ -110,7 +110,7 @@ class FakeStack {
   FakeFrameLifo<kMaxRecursionDepth> call_stack_;
 };
 
-COMPILER_CHECK(sizeof(FakeStack) <= (1 << 17));
+COMPILER_CHECK(sizeof(FakeStack) <= (1 << 19));
 
 }  // namespace __asan
 

Added: compiler-rt/trunk/lib/asan/lit_tests/TestCases/deep_call_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/deep_call_stack.cc?rev=189929&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/deep_call_stack.cc (added)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/deep_call_stack.cc Wed Sep  4 05:59:32 2013
@@ -0,0 +1,23 @@
+// Check that UAR mode can handle very deep recusrion.
+//
+// RUN: %clangxx_asan -fsanitize=use-after-return -O2 %s -o %t && \
+// RUN:   %t 2>&1 | FileCheck %s
+#include <stdio.h>
+
+__attribute__((noinline))
+void RecursiveFunc(int depth, int *ptr) {
+  if ((depth % 1000) == 0)
+    printf("[%05d] ptr: %p\n", depth, ptr);
+  if (depth == 0)
+    return;
+  int local;
+  RecursiveFunc(depth - 1, &local);
+}
+
+int main(int argc, char **argv) {
+  RecursiveFunc(40000, 0);
+  return 0;
+}
+// CHECK: [40000] ptr:
+// CHECK: [20000] ptr:
+// CHECK: [00000] ptr





More information about the llvm-commits mailing list