[compiler-rt] r302898 - Account for stack redzone when computing sp on darwin

Francis Ricci via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 07:10:51 PDT 2017


Author: fjricci
Date: Fri May 12 09:10:51 2017
New Revision: 302898

URL: http://llvm.org/viewvc/llvm-project?rev=302898&view=rev
Log:
Account for stack redzone when computing sp on darwin

thread_get_register_pointer_values handles the redzone computation
automatically, but is marked as an unavailable API function. This
patch replicates its logic accounting for the stack redzone on
x86_64.

Should fix flakiness in the use_stack_threaded test for lsan on darwin.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_mac.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_mac.cc?rev=302898&r1=302897&r2=302898&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_mac.cc Fri May 12 09:10:51 2017
@@ -170,6 +170,10 @@ PtraceRegistersStatus SuspendedThreadsLi
   internal_memcpy(buffer, &regs, sizeof(regs));
   *sp = regs.SP_REG;
 
+  // On x86_64 and aarch64, we must account for the stack redzone, which is 128
+  // bytes.
+  if (SANITIZER_WORDSIZE == 64) *sp -= 128;
+
   return REGISTERS_AVAILABLE;
 }
 




More information about the llvm-commits mailing list