There are many causes of program crash, mainly including the following reasons (refer to eventhelix.com)
1. Invalid array indexing the array index is invalid.
Data1 A; // writable upted when B is indexed with 0 xffffffff (-1) due to the incorrect array index, such as B [-1] may destroy
Int B [100]; // declaration of B. Keep in mind that array indexing is a signed operation
Data2 C; // specified upted when index into B is greater than 99 due to the incorrect array index, such as B [100] may damage C
2. Un-initialized pointer operations uninitialized pointer operations
3. Unauthorized buffer operations unauthorized buffer operations
4. The illegal stack operations operation is invalid.
5. Invalid processor operations invalid processor operation
-- Divide by zero attempted by Application
-- Program running in user mode attempted to execute an instruction that can only be executed in supervisor (kernel) mode.
-- Program attempted access to an illegal address. the address might be out of range or the program might not have the privilege to perform the access. for example, a program attempting to write to read only segment will result in an exception.
-- Misaligned access to memory also results in an exception. most modern processors restrict long word reads to addresses divisible by 4. an exception will be raised if a long word operation is attempted at an address that is not divisible by 4. (See the byte alignment and ordering article for details)
6. Infinite Loop
Common detection and troubleshooting methods
1. Assert
2. output intermediate results print/log
3. Use the Debugger GDB/ddd
4. Use the detection tools memwatch, valgrind, parasoft C ++ test/insure C ++
FAQ:
1. How to make the program generate a core dump file when an error occurs
VI/etc/profile
# No core files by default
# Ulimit-s-c 0>/dev/null 2> & 1
Ulimit-s-c unlimited>/dev/null 2> & 1
2. If the required information is obtained from the Core File
GDB program core. xxx
BT
Info locals
Frame x
Links:
Http://www.eventhelix.com/RealtimeMantra/Basics/debugging_software_crashes.htm
Http://www.eventhelix.com/RealtimeMantra/Basics/debugging_software_crashes_2.htm