PDA

View Full Version : Sigsegv



babygal
25th October 2010, 10:21
What is SIGSEGV ? and what causes it?

Zlatomir
25th October 2010, 10:37
That is a signal OS gives to a process when it makes an invalid memory reference (aka Segmentation Fault) and most of the reasons are pointer mistakes: dereference a null pointer, write beyond and array size-1 (buffer overflow), using uninitialized pointers, attempt to access/alter memory the program does not own, double deletion (careful with the parent-child relation ship, what the parent delete and what you must delete or create on stack)

babygal
2nd November 2010, 06:18
How to detect and pinpoint which one is the actual root cause?

tbscope
2nd November 2010, 06:29
There are a couple of techniques you can use.

You can use a debugger. Set a couple of break points and analyse the code.
You can run a static code analyser which analyses the code before it is run to find possible problems.
You can run a memory checking utility like Valgrind to see where problems might be, although Qt isn't really good to be used with memory checking tools since Qt does its own memory management in some base classes which confuse some of those tools.

Or, you can simply write a few qDebug() << "..." lines and narrow down to the problem. This method will require more time though.