Why Would Gdb Hang

Why would gdb hang?

I'd say the debugged process wouldn't sit idle if it was the cause of the hang. Every time GDB has completed a step, it has to update any expressions you required to print. It may include following pointers and so, and in some case, it may fail there (although I don't remind of a real "hang"). It also typically try to update your stack trace. If the stack trace has been corrupted and is no longer coherent, it could be trapped into an endless loop. Attaching gdb to strace to see what kind of activity is going on during the hang could be a good way to go one step further into figuring out the problem.

(e.g. accessing sources through a no-longer-working NFS/SSHFS mount is one of the most frequent reason for gdb to hang, here :P)

gdb hanging when attaching to java process

Finally found out what was going on. Java uses SIGSEGV during garbage collection, which is intercepted by gdb causing an apparently crash. To solve this I added handle SIGSEGV pass nostop to my ~/.gdbinit file.

GDB hangs during remote debugging, library version mismatches

Upgrading versions, while a very large headache, could be possible but probably should not be necessary...

This is the right option. All of the other issues you are encountering are because of this.

I've tried this in another virtual machine and I even built a fresh dedicated linux install (so no vm), rebuilt the software, and I get the same behavior. So it appears the issue is probably on the target machine's configuration.

You should build on the same version, architecture, etc. as the system you are attempting to deploy your code to.

But then when I try to set breakpoints, I get Error accessing memory address 0xb5eb60: Input/output error.

Per this answer,

Can be caused by 32/64 bit mixups. Check, for example, that you didn't attach to a 32-bit binary with a 64-bit process' ID, or vice versa.

I also tried putting the libc from the host computer onto the target machine, and it won't even boot, it gets a segfault in libc.

Don't do that. As you've found out, it won't work.

So how do I get gdb to load different libraries?

Per this question, you can use LD_LIBRARY_PATH.



Related Topics



Leave a reply



Submit