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

Jay Foad jay.foad at gmail.com
Sun Dec 28 13:32:41 PST 2014


Here is the stack trace at the point of failure and the value of &rl:

  (gdb) bt
  #0  0x00003fffa7748a28 in __nanosleep_nocancel () from /lib64/libc.so.6
  #1  0x00003fffa774881c in .__sleep () from /lib64/libc.so.6
  #2  0x0000000010144110 in __sanitizer::CheckFailed (
      file=0x10179600 "/home/foad/llvm-project/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc", line=94, 
      cond=0x101796c8 "(((uptr)&rl >= start && (uptr)&rl < end)) != (0)", v1=0, v2=0)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.cc:124
  #3  0x000000001015d424 in __sanitizer::GetThreadStackTopAndBottom (at_initialization=true, stack_top=0x3fffe798f960, 
      stack_bottom=0x3fffe798f968)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:94
  #4  0x000000001015da44 in __sanitizer::GetThreadStackAndTls (main=true, stk_addr=0x3fffa72b0020, stk_size=0x3fffa72b0028, 
      tls_addr=0x3fffa72b0030, tls_size=0x3fffe798f9f0)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:306
  #5  0x000000001013fc60 in __asan::AsanThread::SetThreadStackAndTls (this=0x3fffa72b0000)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_thread.cc:200
  #6  0x000000001013f8a8 in __asan::AsanThread::Init (this=0x3fffa72b0000)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_thread.cc:155
  #7  0x000000001013fab8 in __asan::AsanThread::ThreadStart (this=0x3fffa72b0000, os_id=19870, signal_thread_is_registered=0x0)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_thread.cc:169
  #8  0x000000001013d9c8 in __asan::AsanInitInternal () at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc:425
  #9  0x000000001013dca0 in __asan_init_v5 () at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc:509
  #10 0x00003fffa7c37f88 in ._dl_init_internal () from /lib64/ld64.so.1
  #11 0x00003fffa7c23d5c in ._dl_start_user () from /lib64/ld64.so.1
  (gdb) up 3
  #3  0x000000001015d424 in __sanitizer::GetThreadStackTopAndBottom (at_initialization=true, stack_top=0x3fffe798f960, 
      stack_bottom=0x3fffe798f968)
      at /home/foad/llvm-project/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:94
  94	    CHECK((uptr)&rl >= start && (uptr)&rl < end);
  (gdb) p/x $sp
  $1 = 0x3fffe798f780
  (gdb) p &rl
  $2 = (rlimit *) 0x3fffe798f870

Here is the stack mapping from /proc/*/maps:

  3fffe7990000-3fffe79a0000 rw-p 00000000 00:00 0                          [stack]

And from /proc/*/smaps:

  3fffe7990000-3fffe79a0000 rw-p 00000000 00:00 0                          [stack]
  Size:                128 kB
  Rss:                 128 kB
  Pss:                 128 kB
  Shared_Clean:          0 kB
  Shared_Dirty:          0 kB
  Private_Clean:         0 kB
  Private_Dirty:       128 kB
  Referenced:          128 kB
  Anonymous:           128 kB
  AnonHugePages:         0 kB
  Swap:                  0 kB
  KernelPageSize:       64 kB
  MMUPageSize:          64 kB
  Locked:                0 kB
  VmFlags: rd wr mr mw me gd ac

Note that Size is 128k, but the difference between the start and end addresses is only 64k! This machine has 64k pages.

Linux's proc fs seems to think that there is a "stack guard page" at address 0x3fffe7980000, but I don't understand why, because it appears to be both readable and writable.


http://reviews.llvm.org/D6777

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






More information about the llvm-commits mailing list