Skip to main content
gamedev.net
🔒 Locked

Help. Base class pointer to Input processing class error.

Started by Nocturnus 4 replies 1k views
Original Post
Nocturnus
Nocturnus
I created this framework for a game engine I wanted to make. The input processing uses a base class defined in the TFramework.h and TFramework accesses the Input Processing through a call using a base class pointer. The problem is that when I compile and try to run the program I get this error. Unhandled exception at 0x00812999 in Pod And Rodney.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd. I'm not exactly sure what that means, other than a memory violation. Any solutions would be great. I've included a link to a .rar file that contains the code in hopes that this might help too. Edit: http://www.megaupload.com/?d=5UR63DK3 Thanks for any help.
SiCrane
SiCrane
0xCDCDCDCD is a memory pattern written to freshly allocated memory by the MSVC debug runtimes. If you get an access violation reading that location it means that you probably tried to dereference an unintialized member variable of a pointer type.
Nocturnus
Nocturnus
Could you kind of elaborate on that?

Thanks
megamoscha
megamoscha

int* p = new int;
std::cout << std::hex << *p << std::endl; // *p has the value 0xcdcdcdcd
fcoelho
fcoelho
When you do a debug build under MSVC, variables are initialized for you to make it easier to find problems in the code. Allocated memory is initialized with 0xCDCDCDCD, so, you're (probably) trying to access a pointer or something in newly allocated memory. Shouldn't the debugger tell you where in the code the access violation happened?
SiCrane
SiCrane
This is an example of the kind of code that would generate that error:
struct Foo {  int * bar;    int fu(void) { return *bar; }};int main(int, char **) {  Foo * baz = new Foo;  baz->fu(); // access violation  *(baz->bar) = 0; // access violation  return 0;}

Here baz->bar is an uninitialized member variable of a pointer type. Reading or writing to that location would generate an access violation at 0xCDCDCDCD in a MSVC debug build.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.