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.

Add New Comment
Viewing 4 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)