Debug Error Damage After Null Block
to Page... Thread Tools Search this Thread Rate Thread #1 01-Apr-2008, 14:38 phylao New Member Join Date: Mar 2008 Posts: 12 Damage: After Normal Block (#xxx) at 0x0xxxx error Hello, I got this error after I run my program. Debug Error: DAMAGE: After Normal Block (#xxx) at 0xxxxxxxx.... and I could only choose to abort or retry (debug). I isolated the program (keep running with comments) and found out the error occurs when I have this piece of code. CPP / C++ / C Code:
// now for each pointer, free its array of floats for (a = 0; a < num_azimuth; a++) free(map0_values[a]); // now free the array of pointers free (map0_values);I have a malloc for the map0_values 2 D array as follows declared in the beginning of this function: CPP / C++ / C Code:
float **map0_values; // initialization map0_values = (float **)malloc((num_a - 1) * sizeof(float *)); if (map0_values == NULL) { fprintf(stderr, "out of memory\n"); return; } for (int a = 0; a < num_a; a++) { map0_values[a] = (float *)malloc((number_x) * sizeof(float)); if (map0_values[a] == NULL) { fprintf(stderr, "out of memory\n"); return; } }If I comment out that free memory code, the program seem to work fine (actually, the program seem to work fine, even with this error, I had output files created and I compare the two,
Forum Visual C++ & C++ Programming Visual C++ Programming Debug Error: Damage after normal block If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 5 of 5 Thread: Debug Error: Damage after https://www.gidforums.com/t-17789.html normal block Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode December 8th, 2005,09:31 AM #1 Joe Johnston View Profile View Forum Posts Junior Member Join Date Dec 2005 Posts 3 Debug Error: Damage after normal block Getting a Debug Error: Damage after normal block. http://forums.codeguru.com/showthread.php?367849-Debug-Error-Damage-after-normal-block Guess its when I'm using the delete [] str but can't trace the error. Help much appreciated. Code: // strng3.h -- String class definition //MODIFY AS NEEDED #ifndef _STRNG3_H_ #define _STRNG3_H_ #include
Bytes;BYTE *pData = NULL;if (!GetProfileBinary((LPCTSTR)lpszSection, lpszEntry,&pData, &Bytes)) {..}...if ( pData )delete [] pData;The last line (delete []) in Debug build causes theerror:DAMAGE: after normal block (#xxx) at 0x0....After debug http://microsoft.public.vc.debugger.narkive.com/qjwruFKB/damage-after-normal-block-heap-error-in-debug I found that the error is generated indbgheap.c module at line 1150.After choosing continue another dialog appears saying:Unhandled exception at 0x1... (msvcr71d.dll) in x.exe:User breakpoint.And then the program continues normally till next timethe code is executed.The pData contains always 14 bytes of data, here is thesample:Data: <20040104004950> 32 30 30 34 30 31 30 34 30 30 3439 35 30For debug error me it seems like bug in the heap handling in Debugmode. The same happened when I used the VC++ 6.Does anybody have an idea how to fix it?The error does not appear in the Release build.Regards,Krzysztof Scott McPhillips [MVP] 2004-01-04 16:11:34 UTC PermalinkRaw Message Post by Krzysztof KlimczakHi all,CString lpszSection;CString lpszEntry;UINT Bytes;BYTE *pData = NULL;if (!GetProfileBinary((LPCTSTR)lpszSection, lpszEntry,&pData, &Bytes)) {..}...if ( debug error damage pData )delete [] pData;The last line (delete []) in Debug build causes theDAMAGE: after normal block (#xxx) at 0x0.......The error does not appear in the Release build.Regards,KrzysztofThe code that you show looks good. Try commenting out all your othercode (the ... part) that processes the data to see if this eliminatesthe problem. The returned data is not null terminated, so if you useany string functions to process the data those functions will corruptthe memory beyond.The error does not appear in the release build because only the debugbuild checks for heap corruption. The results in a release build areundefined. Something else gets corrupted :)--Scott McPhillips [VC++ MVP] Krzysztof Klimczak 2004-01-04 21:13:21 UTC PermalinkRaw Message -----Original Message-----Post by Krzysztof KlimczakHi all,CString lpszSection;CString lpszEntry;UINT Bytes;BYTE *pData = NULL;if (!GetProfileBinary((LPCTSTR)lpszSection, lpszEntry,&pData, &Bytes)) {..}...if ( pData )delete [] pData;The last line (delete []) in Debug build causes theDAMAGE: after normal block (#xxx) at 0x0.......The error does not appear in the Release build.Regards,KrzysztofThe code that you show looks good. Try commenting outall your othercode (the ... part) that processes the data to see ifthis