Advertisement

What exactly is a 0xC0000005 Access Violation?

Started by January 23, 2001 03:00 PM
5 comments, last by Galileo430 24 years ago
Simple question. What exactly is a 0xC0000005 Access Violation? How do I stop them? I know one answer is if you try to over read a given file but.. I get it alot of other times too and it makes me want to kill my computer.
------------------------------------------------------------I wrote the best video game ever, then I woke up...
Oh, that''s an easy error to fix! All it means is that: It''s time to get some sunlight and fresh air.
Advertisement
You have a pointer issue. You are stepping out of bounds with an array or something like that. You also could be trying to use an invalid pointer. I assume you have some idea where this is being caused. Are you checking to make all of your pointers are valid? You can also use asserts to see where you have bad pointers. If you have a copy of the code that may be causing this that would help a lot. You definitely have a pointer problem though.


Zooraider
Memory can be read/write, read-only, no access at all, etc.

Access Violation (AV) means you''re trying to use the memory in a way that isn''t allowed. Writing to read-only memory for example. Or reading from memory marked as no access.

Like others said, you''re using an invalid pointer. Most of the time when you get this you''re trying to use a NULL pointer. Windows set the memory at location 0 to no access. So if you try to use a NULL pointer you''re get an AV.

-Mike
Yeah, It''s like kissing you best friend''s girlfriend
Seriously, above is right, you need to add some bound check to your code. Somewhere you are writing/reading outside some array, or to some invalid pointer.

/ Tooon
When you get a 0xC0000005 Access Violation, the most common cause, by far, is that you are trying to do something to a NULL pointer. For example, you pass a pointer to a struct to a function, then try to do:

Value = structPointer->SomeVar;

That would throw an 0xC0000005 (NULL) violation if the structPointer was not valid, as the member attribute ''SomeVar'' does not exist for an item of type NULL.

The simplest way to resolve your problem is to validate all parameters passed to functions, and used locally (or globally) by comparing them to NULL.
Advertisement
These access violations also will occur from source code build issues.
This means that a module''s code pointer could have changed and cause a function or code''s location could move.
A good example are Virtual Function Tables (VTable) in classes. If you add a new virtual function to a class then each virtual function (except the constructor and destructor) will change its location in the VFTable. In turn, any modules that have used this class in the past will need to be rebuilt to ensure that their VFTables are correct. If this is not done, then you will get Access Violations will using this class. However, the class might work sometimes (luckily).

This topic is closed to new replies.

Advertisement