This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to find the mutex lock holder in pthread program?


On Mon, Feb 22, 2010 at 12:26 AM, Han <keepsimple@gmail.com> wrote:
> Hi,
> I am using pthread in a C program. I found my program randomly hung
> because one thread failed to obtain the mutex lock. The error code is
> EBUSY. I am wondering how can I find out what is the thread holding
> the mutex lock at that point?
>
> thanks.
> Han
>

Hi Han,

Use GDB (Gnu Debugger) and attach it to the hung program.  Then use
"thread apply all bt" (I think but I don't have a system handy).

It'll give you a backtrace of all of the threads and you should be
able to see which thread is doing what.

If this problem is easily reproducible too you can use strace to give
you some info one which locks are being taken.

Ryan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]