mailing list of musl libc
 help / color / mirror / code / Atom feed
* _Unwind_Backtrace crashes
@ 2015-08-27 18:55 Andy Lutomirski
  2015-08-27 19:14 ` Rich Felker
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andy Lutomirski @ 2015-08-27 18:55 UTC (permalink / raw)
  To: musl

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)
{
    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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-28 14:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-27 18:55 _Unwind_Backtrace crashes Andy Lutomirski
2015-08-27 19:14 ` Rich Felker
2015-08-27 20:00 ` Szabolcs Nagy
2015-08-28 13:21 ` Alexander Monakov
2015-08-28 14:16   ` Szabolcs Nagy
2015-08-28 14:46     ` Alexander Monakov

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).