[PATCH] fix missing backtraces on macOS by using _Unwind_Backtrace
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 17:08:03 PST 2016
On Fri, Nov 11, 2016 at 1:55 PM, Bob Wilson via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> This is a follow up to r270276:
>
> commit f77c43d1f362f817c7801f48c59b715eae726613
> Author: Richard Smith <richard-llvm at metafoo.co.uk>
> Date: Fri May 20 21:18:12 2016 +0000
>
> Reinstate r269992 (reverting r270267), but restricted to cases where glibc is
> the C standard library implementation in use.
>
> This works around a glibc bug in the backtrace() function where it fails to
> produce a backtrace on x86_64 if libgcc / libunwind is statically linked.
>
> It turns out that Darwin’s backtrace() function does not work with sigaltstack (which was enabled when available with r270395) — it does a sanity check to make sure that the current frame pointer is within the expected stack area (which it is not when using an alternate stack) and gives up otherwise. I’ve asked to see if we can get that fixed, but even if we do, it will take a while to get it released. I’d rather not disable the use of sigaltstack on macOS so instead I tried using the _Unwind_Backtrace code. It seems to work fine. The comment there says that it does not work on FreeBSD, and the commit above changed it to only be used with glibc. Is there any reason why it shouldn’t be used for macOS? I’d like to apply this simple patch to do that. Note that we then use backtrace_symbols_fd() with the addresses from _Unwind_Backtrace, but I’ve tested that and it seems to work fine.
>
LGTM
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list