views:

69

answers:

3

I've run into an exception and looking at variables in the watch window, I'm seeing some question marks (???). Does this mean it's pointing to an invalid address?

+1  A: 

It means that the debugger can't figure out its value.

For example, you see this quite a bit if your code involves HWNDs. If you look through the Windows header files, it's defined like this via a macro:

struct HWND__{int unused;}; typedef struct HWND__ *HWND;

So the type of HWND is really the type "pointer to an HWND__". However, the HWND values you get from functions like CreateWindow() aren't actually pointers to anything.

But the debugger will try to figure out the value of the unused member in the struct, but can't do it:

Watch Window

You will also see these kinds of errors when the watched variable has bad or missing type information.

In silico
Not true. The ??? error string is related to bad type information. If it can't evaluate the expression it will provide a more useful error message
JaredPar
@JaredPar: My wording is a bit off. What I meant was that the debugger can't figure out its value.
In silico
Gotcha. The editted version cleared up the confusion. But it does display the ??? for bad types and bad values.
JaredPar
@JaredPar: Correct. You do see some "false-positives" because of the way some types are defined, like HWNDs, but generally it will happen for bad types and values that throw the debugger off.
In silico
+1  A: 

Is this a C++ style project?

The debugger typically uses the "???" string when it is able to evaluate an expression but is unable to garner any type information for a specific part of the display. This typically occurs because of missing or incorrect PDB symbols.

There is likely a way for this to occur if the expression is accessing corrupted data (overriten virtual tables or RTTI). But I do not 100% know if that is true.

JaredPar
+1  A: 

Usually it means the pointer or reference is pointing to inaccessible memory, and thus it cannot get the value to present. For example, if you have a pointer that's supposed to point to a Foo, the debugger will normally interpret the bits that the pointer points to as a Foo--whether the pointer is valid or not. But in some cases, a wild pointer might point to a location that's not even mapped in the process space. In that case, the debugger cannot get the bits.

Adrian McCarthy