From 0565e00b93a5346273ce49cf7706ebc642162272 Mon Sep 17 00:00:00 2001 From: Andrei Polushin Date: Wed, 13 Jul 2022 02:09:10 +0700 Subject: [PATCH] Disable sigaltstack() on macOS to make backtrace() work. There are many reports that sigaltstack() on Apple platforms stops backtrace() from tracing an original stack, e.g. * https://github.com/llvm/llvm-project/commit/d39ead41056b00d10b6223543562cd304307ac9b * https://reviews.llvm.org/D28265 If we disable an alternate stack for signal handler, we won't be able to catch stack overflow errors, but backrace() will work again. --- absl/debugging/failure_signal_handler.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc index affade3b..c6243305 100644 --- a/absl/debugging/failure_signal_handler.cc +++ b/absl/debugging/failure_signal_handler.cc @@ -50,7 +50,9 @@ #ifndef _WIN32 #define ABSL_HAVE_SIGACTION // Apple WatchOS and TVOS don't allow sigaltstack -#if !(defined(TARGET_OS_WATCH) && TARGET_OS_WATCH) && \ +// Apple macOS has sigaltstack, but using it makes backtrace() unusable. +#if !(defined(TARGET_OS_OSX) && TARGET_OS_OSX) && \ + !(defined(TARGET_OS_WATCH) && TARGET_OS_WATCH) && \ !(defined(TARGET_OS_TV) && TARGET_OS_TV) && !defined(__QNX__) #define ABSL_HAVE_SIGALTSTACK #endif