[PATCH] D33072: Account for stack redzone when computing sp on darwin

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 10 13:42:09 PDT 2017


fjricci created this revision.

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.


https://reviews.llvm.org/D33072

Files:
  lib/sanitizer_common/sanitizer_stoptheworld_mac.cc


Index: lib/sanitizer_common/sanitizer_stoptheworld_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_stoptheworld_mac.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_mac.cc
@@ -170,6 +170,11 @@
   internal_memcpy(buffer, &regs, sizeof(regs));
   *sp = regs.SP_REG;
 
+// On x86_64, we must account for the stack redzone, which is 128 bytes.
+#if defined(__x86_64__)
+  *sp -= 128;
+#endif
+
   return REGISTERS_AVAILABLE;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33072.98527.patch
Type: text/x-patch
Size: 490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170510/2d4d8fce/attachment.bin>


More information about the llvm-commits mailing list