libunwind-devel
[Top][All Lists]
Advanced

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

Re: [Libunwind-devel] using libunwind in signal handler for mult-thread


From: Hui Zhang
Subject: Re: [Libunwind-devel] using libunwind in signal handler for mult-thread program
Date: Tue, 1 Mar 2016 16:39:23 -0500

hello, Milian

Thank you !
This looks like a very particular issue with libunwind. But in my case: 1. I don't know if dl_iterate_phdr is used in my program. 2. My crash seems to be non-termination(or keeping signalling itself), but deaklock shall appear as permanently "pause" , right ?

Thanks

On Tue, Mar 1, 2016 at 8:36 AM, Milian Wolff <address@hidden> wrote:
On Monday, February 29, 2016 6:10:33 PM CET address@hidden wrote:
> Hello, everyone
>
> Did anyone have success in using libunwind in signal handler for
> multi-threads program ? I found the doc says local-unwinding is
> thread-safe and signal-safe, but I'm still having issues with it..
>
> In my program, a handler is called once every certain amount of CPU
> cycles(use PAPI_overflow). And the program is multi-threading. So In the
> handler, I did this:
>
> unw_cursor_t cursor;
> unw_word_t ip, sp;
> unw_context_t uc;
>
> int count=0;
>
> unw_getcontext (&uc);
> if (unw_init_local (&cursor, &uc) < 0)
> fprintf (stderr,"unw_init_local failed!\n");
>
> while (unw_step(&cursor)>0) {
> unw_get_reg (&cursor, UNW_REG_IP, &ip);
> unw_get_reg (&cursor, UNW_REG_SP, &sp);
> printf("%d 0x%lx\n", count, (unsigned long) ip);
> count++;
> }
>
> This works fine for single-thread programs, and also works for small
> muli-thread program, but when I tested lulesh multi-theading program, the
> hanlder would go into a infinite loop, it looks like the handler was kept
> invoked infinitely...Am I using libunwind right ? what should be
> specifically done for multi-threads ?

You must not use printf in a signalhandler. Also, there have been reports of
dl_iterate_phdr causing lockups, which you may hit here. I suggest you follow
up on that by reading the "dl_iterate_phdr deadlock in unw_step" thread on
this mailing list.

Cheers

--
Milian Wolff
address@hidden
http://milianw.de



--
Best regards


Hui Zhang

reply via email to

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