Why is gdb freezing?

I have an application that I am debugging, and I am trying to understand how gdb works and why I can not execute the application sometimes. The problem that I am facing is that gdb will freeze and the process it is attached to will go down when I go through the program. After gdb freezes and I have to kill it to free the terminal (ctrl-C does not work, I have to do it from another terminal window, get the process ID for this gdb session and use kill -9).

I assume gdb hangs because it waits for the application to stop on the next instruction, and somehow the application terminates without gdb, identifying this. But this is just a reflection on my part about the behavior that I have observed so far. So my question is that anyone has seen this type of behavior before and / or could have guessed what might be the cause. I think this can help me improve my debugging strategy.

In case this is important, I am using g ++ 4.4.3, gdb 7.1, running on Ubuntu 10.04 x86_64.

+8
linux g ++ gdb
source share
2 answers

I would say that the debugged process will not sit idle if this is the cause of the hang. Each time GDB completes a step, it must update any expressions necessary for printing. It may include the following pointers, and therefore, and in some cases, it may fail (although I do not recall a real β€œhang”). It also usually tries to update the stack trace. If the stack trace is damaged and is no longer coherent, it can be captured in an infinite loop. Attaching gdb to strace to see what happens when it hangs can be a good way to take another step in solving the problem.

(for example, accessing sources through a non-working NFS / SSHFS mount is one of the most common reasons for gdb to hang: P)

+4
source share

I had a similar problem and it was solved by sending a CONT signal to a debugged process.

+1
source share

All Articles