libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libunwind-devel] unwinding from signal handler (ARM)


From: Ken Werner
Subject: Re: [Libunwind-devel] unwinding from signal handler (ARM)
Date: Fri, 19 Aug 2011 16:53:18 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11

On 08/19/2011 02:39 PM, Sven Neumann wrote:
Hi,

we are using libunwind for a while now to obtain backtraces for crash
reports. This on an ARM with EABI. Right now we are using a somewhat
outdated git snapshot (99e60be), but I'm currently trying to update to
1.0-rc1. I don't have much success though.

With 99e60be we had the problem that we could not unwind from a signal
handler. But that is exactly what we need to do since we want to get a
backtrace from the signal handler that is called when the application
crashes (usually signal 11). We found a workaround though, instead of
calling unw_getcontext() to get an initial unw_context_t pointer to pass
to unw_init_local(), we use the pointer that we got from the signal
handler. Here's some pseudo code for this:

     struct sigaction new_action;

     new_action.sa_sigaction = logCrash;
     sigemptyset (&new_action.sa_mask);
     new_action.sa_flags = SA_SIGINFO;

     sigaction(SIGSEGV,&new_action, NULL);
     sigaction(SIGFPE,&new_action, NULL);

and in logCrash we do something along the lines of:

static void
logCrash(int sig, siginfo_t *info, void *ctx)
{
   unw_init_local(&cursor, ctx);

   do
   {
     char        name[128];
     unw_word_t  valp;
     unw_word_t  offset;
  unw_getcontext()
     if (unw_get_reg(&cursor, UNW_REG_IP,&valp) != 0)
       break;

     /* log function name etc. here */

     ret = unw_step (&cursor);
   }
   while (ret>  0);
}

This worked reasonably well giving us a nice stack trace most of the
time.

Hi Sven,

This code is looking strange to me because unw_getcontext() gets called in a loop. But we might focus on the new code instead.

Now I've updated libunwind to 1.0-rc1 and this trick doesn't seem to
work any longer. The code appears to crash in libunwind if used as
above. I had a look at the ARM implementation and found that there is
now code that's supposed to unw_step a signal handler. So I tried
without our hack and just use unw_getcontext(). Now it doesn't crash any
longer, but it also doesn't unwind over the signal handler. All I get is
a stack trace like this:

0x4016cde0 logUnwind() from /usr/lib/libraumfeld-1.0.so.0
0x40205654 ?? from /usr/lib/libunwind.so.7

Any ideas what we could do?

Hmm, this is interesting. How does your system look like (which libc, kernel version) and are you stepping over RT or non-RT signal frames? It would be helpful if you could share some code that shows the described behavior. In the meanwhile I'll prepare a simple testcase where I'll verify that it's working on my system.

Regards
Ken



reply via email to

[Prev in Thread] Current Thread [Next in Thread]