Strange VS2012 Debug Problem

Started by
1 comment, last by Pink Horror 9 years, 9 months ago

Hi guys,

I don't think this has ever happened before and it's really weird.

struct Joint{

char name[32];

int count;

};

In my program:

Joint* joint=getJoint(...); // i get a good Joint pointer back

if(joint){...

Normally when I debug and hover over a struct variable it has a little popup with the member variables. If I hover the variable 'joint' above I now get this:

cb=1970235507

ver=1919247468

offszCwd=3435973868

offszCommand=3435973836

ichOutfile=3435973836

offszLibs=3435973836

...and when I put it in the watch window it says:

joint->count : class "Joint" has no member 'count'

And it doesn't just happen with Joint. I made sure I'm running the debug build, What's going on ?

Thanks.

Advertisement
Those specific values are useful to memorize. For fun, convert your display to hex. You'll see 3435973836 turn to 0xcccccccc.

That is one of many bit patterns used by the debugging libraries to help you know what happened. That one specifically is uninitialized stack values.

Some common bit patterns in Windows development:

0xCCCCCCCC Uninitialized locals (on the stack)
0xCDCDCDCD Uninitialized (allocated on the heap but not initialized by your program)
0xDDDDDDDD Freed memory (released by delete or free, but remains allocated to the program for debug tracking purposes)
0xBAADFOOD Allocated by heap management functions rather than new or *alloc, uninitialized memory your program owns
0xDEADBEEF Deallocated heap memory your program no longer owns
0xABABABAB and 0xBDBDBDBD Guard memory located outside (before and after) an allocated memory block
0xFDFDFDFD No man's land (normally outside of a process, but also used for certain guard blocks)


So with your value, the debug library is telling you that you never initialized the value. In release mode the value will not be initialized to anything, it will just contain whatever value it had earlier.

If you thought you initialized it with something, you will need to track down inside that code to see why it is returning an uninitialized value instead of a valid (or NULL) pointer.

Joint* joint=getJoint(...); // i get a good Joint pointer back


How do you know it's a "good" Joint pointer?

This topic is closed to new replies.

Advertisement