Subj : Re: gdb detach strange behaviour RHEL 3.0 To : comp.programming.threads From : steve Date : Tue Jul 12 2005 12:11 am In article <1121095178.805498.139610@g47g2000cwa.googlegroups.com>, pankajtakawale wrote: >A thread in my process blocks (condWait) on a mutex indefinately >because of bug. But When I attach this process (in blocked state) to >gdb & detach it, blocked thread starts execution & exits successfully. >What would be the reason for this abrupt behaviour? >What does gdb detach do? which signals does it send? >Note : If i dont attach blocked process to gdb, thread blocks on that >mutex indefinately due to bug. It might awaken if you were to send a signal. However, the behavior is perfectly acceptable: It is known as a "spurious wakeup", and condition variables are explicitly allowed to produce them. In this particular case, it's because the ptrace system call needs the process to be in a different state for debugging, and will do magic to get it there. It's perfectly OK for a condition wait to return when that happens. gdb doesn't use a signal, per se, to do this. It goes through the ptrace() machinery inside the kernel. It's a long an ugly process. The reason that thread is blocked is that it is waiting on the condition variable to be signaled. If nothing signals it, there's no reason for the thread to resume. Steve -- Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.8" / 37N 20' 14.9" Internet: steve @ Watt.COM Whois: SW32 Free time? There's no such thing. It just comes in varying prices... .