Elliott C. Back: Technology FTW!

DAMAGE: after Normal block

Posted in Code by Elliott Back on October 23rd, 2004.

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.

Viewing 4 Comments

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus