views:

74

answers:

2

I have seen many errors over the course of my computer-using life, and a lot of them seemed to be Access Violation Exceptions calling way out into non-readable memory or 0x00000000/0xFFFFFFFF.

What sort of programming error causes this? is it intentional to get the program to crash when something goes very wrong?

+3  A: 

Dereferencing a null pointer (a very common error) can cause this in some languages.

Brian
To be more specific, "in any language which doesn't perform explicit null checks", which pretty much all non-managed ones tend to be.
Pavel Minaev
+3  A: 

Definitely not "intentional to make the program crash when things go very wrong" - they'd just call their language equivalent of exit(error_code) for that... you don't want to randomly jump somewhere in memory to cause it to crash.

Basically it means the program is trying to read a memory location outside of the range allowed it by the operating system.

This requires some kind of pointer concept in the language, and the memory address in the pointer is getting set to a bad value. This could be caused by something like forgetting to set the value of the pointer to be an address of an int it's pointing to and instead setting it to the value the int holds. This could be because of bad data / input handling - you make an array that can hold 256 bytes - and then read 265 in - and it just so happens that a pointer value was in the memory location after the array, so now data that 'spilled over' the end of the array is in the memory location where a pointer was - so next time you access that pointer - it's full of some random data, but it gets treated like a memory address. (Doing this purposefully to hack is called a 'buffer overflow attack').

Nate