View Single Post
  #4 (permalink)  
Old October 2nd, 2003
rockkeys rockkeys is offline
Devotee
 
Join Date: September 30th, 2003
Posts: 27
rockkeys is flying high
Default

Almost all signal 11 crashes (segment faults) are caused by a reference to the object of a null pointer, which is address 0x0000.

In almost every OS, and in every UNIX I have ever used, it is illegal for a program to read from or write to address Zero.

The idea behind this is that no program can ever have address zero as part of it's data, so that reading or writing to that address is indicating a bug. The OS traps this, and tells you that you have accessed a memory segment that doesn't belong to you, or in other words a segment fault.

All UNIX systems (i think) use signal 11 for this, although it could use a different signal, and still map it to the segfault error if needed.

Anyway, if that's happening to you, it most likely because a variable is being used without being initialized to point to valid memory. An uninitialized variable usually is forced to contain a zero, just for that reason. When they are initialized, they are set to some valid address, which then allows the use of the variable normally.

There could be other reasons for this to happen, but the reason above is almost always the cause. An incorrectly formed query, with data missing, and not caught before being processed, could also cause a problem like this. But most programs are very careful with incomming data, and verify that they are valid and complete before trying to process then. But that is a possible second cause for a segfault, and again it indicates a bug (or poor programming).

Regards,
--R
Reply With Quote