libexecinfo backtrace() in a signal handler
Conrad Meyer
cem at freebsd.org
Thu Jul 6 22:58:12 UTC 2017
On Thu, Jul 6, 2017 at 2:02 PM, Marc Branchaud <marcnarc at xiplink.com> wrote:
> Howdy,
>
> (Please CC replies to me, as I am not subscribed. Apologies if I'm in the
> wrong forum!)
>
> I'm trying to use libexecinfo's backtrace() in a SIGSEGV handler. It only
> finds one single frame in the stack, for the signal handler function.
> (Outside of the signal handler backtrace() does return the full stack from
> the call point.)
>
> Is there any way to get the stack from where the SIGSEGV arose? A few hours
> of Googling has proved fruitless.
>
> My overall goal is to intercept core-dumping signals to try to save a
> textual backtrace instead of a full dump (as they can be quite large in my
> application). So I'd also like to catch SIGBUS, and maybe SIGFPE too.
Hi Marc,
Signal handlers use a special stack frame that libexecinfo is too
simple to understand. To get a stack from a signal handler, you might
want to use libunwind instead.
Best,
Conrad
More information about the freebsd-hackers
mailing list