[PATCH] D28265: disable sigaltstack on Apple platforms

Bob Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 16:45:58 PST 2017


bob.wilson created this revision.
bob.wilson added reviewers: mehdi_amini, davide, rsmith, dexonsmith.
bob.wilson added a subscriber: llvm-commits.
Herald added subscribers: mgorny, mcrosier.

Using sigaltstack on Apple platforms is a bad idea. Darwin's backtrace() function does not work with sigaltstack, and my change in r286851 was supposed to solve that by using _Unwind_Backtrace instead. I tested that _Unwind_Backtrace works for crashes but then discovered that it does not work for assertion failures when using sigaltstack, at least on macOS. The stack trace shows only the frames on the alternate stack. I also saw some reports of this happening for crashes, but it fails consistently for assertion failures. I tried various things to get it to work but the problem seems to be in _Unwind_Backtrace itself. Disabling sigaltstack is unfortunate since it would be nice to get backtraces for stack overflows, but at least this gets us backtraces for the more common cases. rdar://problem/29662459


https://reviews.llvm.org/D28265

Files:
  config-ix.cmake


Index: config-ix.cmake
===================================================================
--- config-ix.cmake
+++ config-ix.cmake
@@ -167,7 +167,8 @@
 check_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
 check_symbol_exists(posix_fallocate fcntl.h HAVE_POSIX_FALLOCATE)
 # AddressSanitizer conflicts with lib/Support/Unix/Signals.inc
-if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
+# and backtraces do not work on Apple platforms when using sigaltstack.
+if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
   check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK)
 endif()
 if( HAVE_SYS_UIO_H )


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28265.82969.patch
Type: text/x-patch
Size: 655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170104/a2898b5d/attachment.bin>


More information about the llvm-commits mailing list