[PATCH] [ASan] Fix stack-overflow.cc test on PowerPC64 Linux

Jay Foad jay.foad at gmail.com
Fri Jan 2 04:52:19 PST 2015


I can demonstrate the same failure on x86-64 by setting a low limit on the stack size:

  $ clang -fsanitize=address ~/svn/llvm-project/compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc -o stack-overflow
  $ ulimit -S -s 12 # soft limit stack to 12k
  $ ./stack-overflow
  ==2423==AddressSanitizer CHECK failed: /home/jay/svn/llvm-project/llvm/trunk/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:94 "(((uptr)&rl >= start && (uptr)&rl < end)) != (0)" (0x0, 0x0)
  ASAN:SIGSEGV
  =================================================================
  ==2423==ERROR: AddressSanitizer: stack-overflow on address 0x7fff10736fb8 (pc 0x7fe212b02883 bp 0x7fff10737060 sp 0x7fff10736f40 T0)
      <empty stack>
  
  ==2423==ABORTING

I get the "CHECK failed" message only intermittently, maybe 10% or 20% of the time, depending on the Linux kernel's stack address randomization (which needs to be enabled; make sure that /proc/sys/kernel/randomize_va_space is non-0).

On my PowerPC64 box the page size is 64k. If you run stack-overflow with unlimited stack, it will impose its own limit of 128k, which is only two pages, which I think explains why the failure is more common on PowerPC: the address randomization can give you an initial pc near the beginning of the second page, so the stack quickly grows down into the first page, which is (mis?-)interpreted as a guard page by /proc/maps.


http://reviews.llvm.org/D6777

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list