[PATCH] D45509: [asan] Reduce flakiness in stack-overflow detection

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 19:47:45 PDT 2018


kubamracek created this revision.
kubamracek added reviewers: eugenis, filcab, vitalybuka, kcc, george.karpenkov, delcypher.
kubamracek added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

`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.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D45509

Files:
  lib/sanitizer_common/sanitizer_posix_libcdep.cc
  test/asan/TestCases/scariness_score_test.cc


Index: test/asan/TestCases/scariness_score_test.cc
===================================================================
--- test/asan/TestCases/scariness_score_test.cc
+++ test/asan/TestCases/scariness_score_test.cc
@@ -115,7 +115,7 @@
 }
 
 void StackOverflow(int Idx) {
-  int some_stack[10000];
+  int some_stack[256];
   static volatile int *x;
   x = &some_stack[0];
   if (Idx > 0)
Index: lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -230,7 +230,7 @@
   // take it into account.
   bool IsStackAccess = addr >= (sp & ~0xFFF) && addr < sp + 0xFFFF;
 #else
-  bool IsStackAccess = addr + 512 > sp && addr < sp + 0xFFFF;
+  bool IsStackAccess = addr + GetPageSizeCached() > sp && addr < sp + 0xFFFF;
 #endif
 
 #if __powerpc__


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45509.141943.patch
Type: text/x-patch
Size: 907 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180411/af7eb8ad/attachment.bin>


More information about the llvm-commits mailing list