Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug program with signal handler for SIGSEGV

I am writing a plugin for a application, occasionally a SIGSEGV would be throw out. However, the application catches the signal SIGSEGV. In other word, The plugin is a dynamical library. The error occurs in my plugin and dynamical library. But the applcation handle the sSIGSEGV and exit normally. So, it is quite difficult for me to debug and get the backtrace of all stack frames. Any idea?

Currently I am using gdb as debug tool.

like image 265
Blad Avatar asked Aug 05 '10 12:08

Blad


1 Answers

GDB will catch SIGSEGV before the application does.

What you described in comment to Logan's answer makes no sense.

I suspect what's really happening is that the application creates a new process, and only gets SIGSEGV in that other process, not the one you attached GDB to.

The following commands may be useful if my guess is correct:

(gdb) catch fork
(gdb) catch vfork
(gdb) set follow-fork-mode child

You might also want to edit and expand your question:

  • how do you know there is a SIGSEGV to begin with?
  • Posting a log of your interaction with GDB may also prove useful.
like image 74
Employed Russian Avatar answered Sep 18 '22 17:09

Employed Russian