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: Milian Wolff
Subject: Re: [Libunwind-devel] using libunwind in signal handler for mult-thread program
Date: Tue, 01 Mar 2016 14:36:08 +0100
User-agent: KMail/5.1.75 (Linux/4.4.1-2-ARCH; KDE/5.20.0; x86_64; git-66e52c1; 2016-02-29)

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



reply via email to

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