From 43d2cb123dc9d7caf42f70d8d9c8d909b7684610 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Fri, 6 Jan 2017 02:26:30 +0000 Subject: [PATCH] Disable sigaltstack on Apple platforms 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291206 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/config-ix.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index d4c8c8d9d61..88694aa6eea 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -169,7 +169,10 @@ if( HAVE_SETJMP_H ) check_symbol_exists(siglongjmp setjmp.h HAVE_SIGLONGJMP) check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP) endif() -if( HAVE_SIGNAL_H ) +# Avoid sigaltstack on Apple platforms, where backtrace() cannot handle it +# (rdar://7089625) and _Unwind_Backtrace is unusable because it cannot unwind +# past the signal handler after an assertion failure (rdar://29866587). +if( HAVE_SIGNAL_H AND NOT APPLE ) check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK) endif() if( HAVE_SYS_UIO_H )