On Tue, Jan 8, 2013 at 2:33 PM, Prabhat Verma
<[email protected]>wrote:

> malloc
>   observe_malloc      - our malloc hook
>     unwind_stack      - Linux libunwind implementation
>       unw_step (takes libunwind CACHE lock)
>         dl_interate_hdr (takes dl lock)
>
> The same deadlock may happen while THREAD 1 is in dlsym and other dl
> functions that all internally use the same recursive lock dl lock and
> allocate memory.


This is a well known issue. dl_iterate_phdr in glibc is not async signal
safe. So it's not safe to call from libunwind. One solution is to patch
your glibc to make it async signal safe (trade-off: allocate all the needed
memory upfront or using async signal safe APIs and use atomics where
possible). It's not trivial, but not impossible either.

Other solutions can mask this problem, but on a large enough dataset, this
issue will manifest in other ways.

 -Arun
_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to