summaryrefslogtreecommitdiff
path: root/lib/asan/asan_linux.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2012-05-22 11:54:44 +0000
committerKostya Serebryany <kcc@google.com>2012-05-22 11:54:44 +0000
commit6f350e0d1c385189cb94ddde7b288a2533b45b32 (patch)
tree8d388f9419868e09c3c223aaf53b5c1c206b1c1c /lib/asan/asan_linux.cc
parent26127735454fddae3495794f38189d57dde6510f (diff)
downloadcompiler-rt-6f350e0d1c385189cb94ddde7b288a2533b45b32.tar.gz
compiler-rt-6f350e0d1c385189cb94ddde7b288a2533b45b32.tar.bz2
compiler-rt-6f350e0d1c385189cb94ddde7b288a2533b45b32.tar.xz
[asan] increase the stack size limit to 256M (yes, that happens); also CHECK that the stack size is less than that on a non-main thread
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157249 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_linux.cc')
-rw-r--r--lib/asan/asan_linux.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index fb2e21dc..7fa59d81 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -39,6 +39,8 @@ extern "C" void* _DYNAMIC;
namespace __asan {
+const size_t kMaxThreadStackSize = 256 * (1 << 20); // 256M
+
void *AsanDoesNotSupportStaticLinkage() {
// This will fail to link with -static.
return &_DYNAMIC; // defined in link.h
@@ -294,6 +296,9 @@ void AsanThread::SetThreadStackTopAndBottom() {
size_t stacksize = rl.rlim_cur;
if (stacksize > end - prev_end)
stacksize = end - prev_end;
+ // When running with unlimited stack size, we still want to set some limit.
+ // The unlimited stack size is caused by 'ulimit -s unlimited'.
+ // Also, for some reason, GNU make spawns subrocesses with unlimited stack.
if (stacksize > kMaxThreadStackSize)
stacksize = kMaxThreadStackSize;
stack_top_ = end;
@@ -310,12 +315,7 @@ void AsanThread::SetThreadStackTopAndBottom() {
stack_top_ = (uintptr_t)stackaddr + stacksize;
stack_bottom_ = (uintptr_t)stackaddr;
- // When running with unlimited stack size, we still want to set some limit.
- // The unlimited stack size is caused by 'ulimit -s unlimited'.
- // Also, for some reason, GNU make spawns subrocesses with unlimited stack.
- if (stacksize > kMaxThreadStackSize) {
- stack_bottom_ = stack_top_ - kMaxThreadStackSize;
- }
+ CHECK(stacksize < kMaxThreadStackSize); // Sanity check.
CHECK(AddrIsInStack((uintptr_t)&attr));
}