I have a program which prompts me the error in VS2010, in debug :
Error: Stack around the variable 'x' was corrupted
This gives me the function where a stack overflow likely occurs, but I can't visually see where the problem is.
Is there a general way to debug this error with VS2010? Would it be possible to indentify which write operation is overwritting the incorrect stack memory? thanks
Is there a general way to debug this error with VS2010?
No, there isn't. What you have done is to somehow invoke undefined behavior. The reason these behaviors are undefined is that the general case is very hard to detect/diagnose. Sometimes it is provably impossible to do so.
There are however, a somewhat smallish number of things that typically cause your problem:
free
for something allocated with new
, etc.),This can be caused by several issues, that are generally hard to see:
delete
a variable allocated with new[]
or delete[]
a variable allocated with new
delete
something allocated with malloc
delete
an automatic storage variableIf it's not immediately clear, I'd get my hands on a memory debugger (I can think of Rational Purify for windows).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With