Seeing 0xcdcdcdcd makes me think this problem is less about heap corruption and more about you trying to dereference a bad pointer.
When looking through the call stack the first line of a constructor (after initialization list). It's comming from the .push_back() part of the line |
So... you mean the push_back call is inside your constructor? Or the constructor is being called from push_back?
In any event... the debugger should be snapping on
the exact line where the bad memory access is occurring. It's unlikely this is happening inside push_back, so you might not have to go down on the call stack at all to see where the problem is.
m_Values.push_back(new TExtValue("SomeName", "-", fromHost.Value1));
I'm skeptical that this call is really the source of your problem. It is not dereferencing any pointers other than
this
(and I guess 'fromHost' if that's a reference), so I suspect you are chasing a red herring.
What I'd do first as a sanity check... is examine
this
in your watch window. If it's a bad pointer... then that's your problem. Go down on the call stack until you find the code first referencing this object and you'll find that it's trying to call a member function with a bad pointer.
If
this
is fine (which I suspect), then I think you're misdiagnosing the problem line. Go
all the way up on the call stack and then examine all objects/pointers which are being dereferenced. One of them must be 0xcdcdcdcd.
EDIT: to clarify my terminology.. "up" on the stack would be more recently called functions and "down" would be previously called functions (stack grows up). So main() would be the bottom of the stack (or close to it).
I'm not sure if that's widely accepted. Some people might consider the stack to grow down.