DAMAGE: after Normal block
If you ever get this VS.NET error in C, read on for a fix:
Debug Error! DAMAGE: after Normal block (#97) at 0×00350040.
This was caused by an infite mutual recursion between a rehash() function and the linear probing hash() function, all because I check null but didn’t calloc() the rehashed elements. There are times when malloc() just won’t do. You have to make sure that you initialize elements to NULL before checking against NULL–otherwise they’ll contain garbage.
Another source of this error is a buffer overflow. Imagine if you call
mem = malloc(number_elements)
for an int* array rather than
mem = malloc(number_elements * sizeof(int))
That will be “fine” until you call free(mem): the runtime will tell you that you’ve just damaged your heap.
| This entry was posted on Saturday, October 23rd, 2004 at 6:16 pm and is tagged with mutual recursion, number elements, int array, hash function, buffer overflow, heap, garbage. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback. |
5 Responses to “DAMAGE: after Normal block”
Leave a Reply

same error with the following reason:
added a pointer variable to a base class of my plugins and forgotten to rebuild them. the error arised after deleting a plugin instance, but only when I accessed the member, even if I only set it to 0 in the constructor.
Hey.
Thanks for the help.
It’s obvious programmin error, i know…
But sometimes you just need to be pulled back to the ground.
- Janie
I have a same problem in VC++ 6.0.there are some code as follows:
struct T
{
int * pt;
…
};
struct M
{
vector m_vctT;
…
};
map m_mapM;
M * pM = new M;
m_mapM.insert(make_pair(1,pM);
T * pt = new T;
pt = …
pM->m_vctT.push_back(pt);
so,I write some code for free memory in a destructor function,as follows:
for(map::iterator iter = m_mapM.begin; iter != m_mapM_end();iter++)
{
if((*iter->second) != NULL)
{
delete (*iter->second);
}
}
but run at delete (*iter->second) with debug mode,it report DAMAGE: after Normal block (#XX) at 0×XXXXXXX
who can tell me how to fix this problem? Please mail to me : witton@163.com. Thanks very much!
alloc more any bytes is a bug of the compiler
Thank you so much for explaining this! I knew most of what you said already and yet something about it made it click what my error was. I thought I was already doing as you suggested, but I actually was off by one byte (don't ask).