libunwind-devel
[Top][All Lists]
Advanced

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

[Libunwind-devel] Problem with using libunwind in a ptrace setting where


From: hai huang
Subject: [Libunwind-devel] Problem with using libunwind in a ptrace setting where tracer uses pthread
Date: Wed, 26 Jul 2017 10:53:52 -0400

Hi folks,

I've been using libunwind in an x86_64 Linux environment to do stack walking on ptraced processes with great success. However, that's only when the tracee is single threaded. When the tracee is multi-threaded, I rewrote my tracer program to be multi-threaded using pthread, so that I have a tracer thread for each tracee thread. Each tracer thread has its own libunwind "context", i.e., each thread creates its own libunwind variables as follow:

as = unw_create_addr_space(&_UPT_accessors, 0);
ui = _UPT_create(child);
unw_init_remote(&c, as, ui);

Subsequently, each tracer thread makes unw_step(&c) calls to walk the stack frames of its corresponding tracee thread.

Once I starts the tracer program, I immediately (within a second) see a failure of the call `unw_init_remote(&c, as, ui)`, which returned `-3`. This corresponds to the UNW_EBADREG error.

I'm suspecting I needed some synchronization between my tracer threads as some libunwind states are not multi-threading safe, but I haven't found what exactly I need to protect. Any hints/suspicions would be greatly appreciated! Thanks!

-
Hai

reply via email to

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