|
|
Message-ID: <20150827200005.GF3609@port70.net>
Date: Thu, 27 Aug 2015 22:00:06 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: _Unwind_Backtrace crashes
* Andy Lutomirski <luto@...capital.net> [2015-08-27 11:55:24 -0700]:
> This works on glibc. It aborts on musl on i386 using the latest git version.
>
> I suspect it's because whatever calls main isn't properly annotated,
> but I don't know how to debug this without rebuilding gcc, which is
> kind of a mess.
>
> #define _GNU_SOURCE
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
> #include <unwind.h>
> #include <err.h>
> #include <string.h>
>
> static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),
> int flags)
> {
> struct sigaction sa;
> memset(&sa, 0, sizeof(sa));
> sa.sa_sigaction = handler;
> sa.sa_flags = SA_SIGINFO | flags;
> sigemptyset(&sa.sa_mask);
> if (sigaction(sig, &sa, 0))
> err(1, "sigaction");
> }
>
> _Unwind_Reason_Code trace_fn(struct _Unwind_Context * ctx, void *opaque)
> {
you might want to add
dprintf(1, "ip: %16p cfa: %16p\n", (void*)_Unwind_GetIP(ctx), (void*)_Unwind_GetCFA(ctx));
here, so you see if trace_fn is called at all
(and s/printf/dprintf/g so you see what is printed before the crash)
> return _URC_NO_REASON;
> }
>
> static void sigusr1(int sig, siginfo_t *info, void *ctx_void)
> {
> printf("In signal handler. Trying to unwind.\n");
> _Unwind_Backtrace(trace_fn, 0);
> }
>
> int main()
> {
> printf("Unwind directly\n");
> _Unwind_Backtrace(trace_fn, 0);
>
> printf("Unwind from signal handler\n");
> sethandler(SIGUSR1, sigusr1, 0);
> raise(SIGUSR1);
>
> printf("OK\n");
> }
>
>
> --
> Andy Lutomirski
> AMA Capital Management, LLC
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.