summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2018-04-13 00:29:24 +0000
committerKuba Mracek <mracek@apple.com>2018-04-13 00:29:24 +0000
commit0fb14e944c739baba542882ce1504d00da25c9f7 (patch)
tree9c306d8bbd8f7f2628b953e6382a4336ffff8187
parent8fc5b84349b84d987d5dca8c85490c72a68324df (diff)
downloadbcm5719-llvm-0fb14e944c739baba542882ce1504d00da25c9f7.tar.gz
bcm5719-llvm-0fb14e944c739baba542882ce1504d00da25c9f7.zip
[asan] Reduce flakiness in stack-overflow detection
IsStackOverflow only treats accesses within 512 bytes of SP as stack-overflow. This should really be the size of a page instead. The scariness_score_test.cc triggers stack overflow with frames that are even larger than a page, which can also trigger a fault that will not be recognized as stack-overflow. Let's just use smaller frames. llvm-svn: 329980
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc4
-rw-r--r--compiler-rt/test/asan/TestCases/scariness_score_test.cc2
2 files changed, 4 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc
index 7fbb939753c..e7576000cbc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -230,7 +230,9 @@ bool SignalContext::IsStackOverflow() const {
// take it into account.
bool IsStackAccess = addr >= (sp & ~0xFFF) && addr < sp + 0xFFFF;
#else
- bool IsStackAccess = addr + 512 > sp && addr < sp + 0xFFFF;
+ // Let's accept up to a page size away from top of stack. Things like stack
+ // probing can trigger accesses with such large offsets.
+ bool IsStackAccess = addr + GetPageSizeCached() > sp && addr < sp + 0xFFFF;
#endif
#if __powerpc__
diff --git a/compiler-rt/test/asan/TestCases/scariness_score_test.cc b/compiler-rt/test/asan/TestCases/scariness_score_test.cc
index 171bea9ee19..fb174eb52b2 100644
--- a/compiler-rt/test/asan/TestCases/scariness_score_test.cc
+++ b/compiler-rt/test/asan/TestCases/scariness_score_test.cc
@@ -115,7 +115,7 @@ void DoubleFree() {
}
void StackOverflow(int Idx) {
- int some_stack[10000];
+ int some_stack[256];
static volatile int *x;
x = &some_stack[0];
if (Idx > 0)
OpenPOWER on IntegriCloud