I haven’t done any C++ in a while, but decided to finish a big project I was working on for someone. I am getting the following error message now though…
HEAP CORRUPTION DETECTED: after Normal Block (#1761) at 0x17DEB940.
CRT Detected that the application wrote to memory after end of heap buffer.
I have been stepping through all of the functions I thought might have caused it but I am at a loss. Is there any way using the more advanced debugging features to hunt this down?
It does sound like a classic memory corruption error. The platform would be helpful information. Without seeing your code and it’s complexity there are a couple of possibilities:
I’ll make a guess that the runtime
library would allow you to add calls to the
heap validation code directly from
your code. I would suggest placing
calls to the heap validation code in
various places in your code so you
can figure out where things go
wrong. You’ll find the place where
the heap goes bad and you’ll know
that it was ok at the previous call.
Keep narrowing down that window if
you need to and then review the code
where the problem occurs.
If the same steps corrupt exactly the same place in memory,
you should be able to use your
debugger to set a breakpoint (or watchpoint) on the
memory getting changed. Some of
those changes may be intended, but
you should be able to figure out
which one is the culprit.
You might use a combination of the two if your code is particularly complex or the steps needed to reproduce this are long – narrow down a section of code that it problematic and then place a breakpoint on the memory location that gets corrupted.
david