Debug Error Damage Before Normal Block
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What could cause DAMAGE: after normal block error? up vote 0 down vote favorite I keep getting this error after my application is running for 2 days. I've been told it's been some kind of buffer overflow, but is it the only option? The app is written in C++ using Visual C++ 6.0. c++ visual-c++ share|improve this question asked Apr 27 '09 at 12:57 Rodrigo 2,03252234 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted In debug, when you get dynamic buffer by new, a special code gets inserted before and after the buffer to guard the buffer. Ex:
, Windows Desktop Development > Visual C++ Question 0 Sign in to vote Hi, i have a dynamic byte array "ba". i have used it as follows BYTE *ba = new BYTE[len]; //len is non zero ZeroMemory(ba, sizeof(ba)*(len)); memcpy(ba,p_btPgBodyPtr+f_dwStrtTblOff,len); ... .... .... if(ba) delete [] ba; //i get debug error out here can anybody help me solve this problem thanks Monday, April 06, 2009 4:27 PM Reply | Quote Answers http://stackoverflow.com/questions/793375/what-could-cause-damage-after-normal-block-error 1 Sign in to vote It should be:ZeroMemory(ba, sizeof(*ba)*(len)); Note the extra '*'. Otherwise, sizeof(ba) is 4, right? Marked as answer by nobugzMVP, Moderator Tuesday, April 07, 2009 2:23 AM Monday, April 06, 2009 4:36 PM Reply | Quote All replies 1 Sign in to vote It should be:ZeroMemory(ba, sizeof(*ba)*(len)); Note the extra '*'. https://social.msdn.microsoft.com/Forums/vstudio/en-US/d6dd29e2-5116-41b6-b54b-3e3ac23d4857/debug-error-damageafter-normal-block?forum=vcgeneral Otherwise, sizeof(ba) is 4, right? Marked as answer by nobugzMVP, Moderator Tuesday, April 07, 2009 2:23 AM Monday, April 06, 2009 4:36 PM Reply | Quote 0 Sign in to vote thanks brian that did the trick for me. cheers mate! Tuesday, April 07, 2009 10:36 AM Reply | Quote Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.Would you like to participate? Privacy statement Dev Centers Windows Office More... Related Sites Visual Studio Visual Studio Integrate VSIP Program Microsoft .NET Microsoft Azure Connect Forums Blog Facebook LinkedIn Stack Overflow Twitter Visual Studio Events YouTube Developer Resources Code samples Documentation Downloads Products & extensions for Visual Studio REST APIs Testing tools for web developers Videos and tutorials Virtual Labs United States (English) © 2016 Microsoft Terms of Use Trademarks Privacy Statement Site Feedback
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: https://www.gidforums.com/t-17789.html After Normal Block (#xxx) at 0x0xxxx error Hello, I got this error https://www.experts-exchange.com/questions/21529028/Debug-Error-in-Visual-C-program-Damage-after-Normal-block-56-at-0x00304700.html 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: debug error
// 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, they are the same). I am a super newbie in C++ programming, can anyone tell me what's going on here? Thanks a lot in advance. Last edited by admin : 01-Apr-2008 at 20:02. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags #2 01-Apr-2008, 15:26 fakepoo Regular Member Join Date: Oct 2007 Posts: 969 Re: Damage: After Normal Block (#xxx) at 0x0xxxx error Your error is here: CPP / C++ / C Code:
//map0_valuesfor Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Debug Error in Visual C++ program -- "Damage after Normal block (#56) at 0x00304700" Want to Advertise Here? Solved Debug Error in Visual C++ program -- "Damage after Normal block (#56) at 0x00304700" Posted on 2005-08-16 C++ 1 Verified Solution 2 Comments 1,388 Views Last Modified: 2008-03-06 I recently inherited a "supposedly" running program that I have to provide support and enhancments for. When I attempt to run the code in the Visual C++ 6 IDE, it seems to run fine until the destructor of one of the classes is called. Then I get the following Debug Error: "DAMAGE: after Normal block (#56) at 0x00304700. I've traced the problem down to a "delete" statement, but I haven't been able to determine exactly what's wrong with it. Here's the relevant code: ===== // Header file (.h) class MailRoomStarter : public NTService { private: bool m_running; // Stop the use of default and copy constructors MailRoomStarter(void); MailRoomStarter(MailRoomStarter&); protected: char *m_MailRoomProgramPath; ... } // CPP file (.CPP) MailRoomStarter::MailRoomStarter(const char* srvname, LPSERVICE_MAIN_FUNCTION fpSrvMain, LPHANDLER_FUNCTION fpSrvCtrl ) : NTService(srvname, fpSrvMain, fpSrvCtrl) { char path[MAX_PATH]; mStat.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; GetRegistryString(HKEY_LOCAL_MACHINE, "\\SOFTWARE\\xxx\\yyy\\Common\\ExePath", path); m_MailRoomProgramPath = new char[strlen(path)]; strcpy(m_MailRoomProgramPath,path); } //Destructor MailRoomStarter::~MailRoomStarter(void) { if(m_MailRoomProgramPath != NUL