On Monday, February 29, 2016 6:10:33 PM CET [email protected] 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 [email protected] http://milianw.de _______________________________________________ Libunwind-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/libunwind-devel
