mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: _Unwind_Backtrace crashes
Date: Thu, 27 Aug 2015 22:00:06 +0200	[thread overview]
Message-ID: <20150827200005.GF3609@port70.net> (raw)
In-Reply-To: <CALCETrV9y=DN4TyKo7H-FrH0JD+xUze9H9fqkeHdxAo+3vivHw@mail.gmail.com>

* Andy Lutomirski <luto@amacapital.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


  parent reply	other threads:[~2015-08-27 20:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 18:55 Andy Lutomirski
2015-08-27 19:14 ` Rich Felker
2015-08-27 20:00 ` Szabolcs Nagy [this message]
2015-08-28 13:21 ` Alexander Monakov
2015-08-28 14:16   ` Szabolcs Nagy
2015-08-28 14:46     ` Alexander Monakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150827200005.GF3609@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).