brachistochron
brachistochron

Reputation: 321

Can't get stacktrace when SIGSEGV using gdb

I have web daemon and request that makes it fail with SIGSEGV. So i start daemon, attach with gdb, continuing, send request and getting this:

$ gdb attach -p 630066

(gdb) c
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) 

How to make gdb print stacktrace before killing application? Application do not have subprocesses, just threads.

Thanks.

Upvotes: 0

Views: 3264

Answers (2)

Employed Russian
Employed Russian

Reputation: 213947

Your GDB session indicates that you have not attached all threads of the multithreaded process, and some other thread (one you didn't attach) ran into SIGSEGV and terminated the entire process.

Another (somewhat unlikely) possibility is that you are using a very old version of GDB, one which still has this bug in it (the bug was fixed in 2009).

When using gdb -p NNNN you need to be careful and specify correct process id. pgrep daemon-name or ps aux | grep daemon-name should give you a good idea which process to attach.

Upvotes: 2

Alexander Lapenkov
Alexander Lapenkov

Reputation: 605

Just enter backtrace or bt right in the gdb shell after getting SIGSEGV. To explore stack trace for each separate thread, start with info thread, then choose the thread you need, for example thread 3 and then type bt to see the stack trace for that thread.

Upvotes: 0

Related Questions