memory - Is there any way of preventing application from crashing when heap is corrupted? - C programing language -
sometimes in execution error message in vs2010 when trying free memory:
windows has triggered breakpoint in [appname].exe.
this may due corruption of heap, indicates bug in [appname].exe or of dlls has loaded.
this may due user pressing f12 while [appname].exe has focus.
the output window may have more diagnostic information.
wich means wrong heap or pointer.
my issue error crashes app when built release.
also module of bigger application , when crashes everithing goes down.
i able handle error.
from msdn on "free":
if error occurs in freeing memory, errno set information operating system on nature of failure. more information, see errno, _doserrno, _sys_errlist, , _sys_nerr.
there errno_t _get_errno( int * pvalue );
function returns error code.
if press continue on error msg shown above function returns error code. using code can detect error, create call stack , exit function softly.
is there compiler switch or prevent aplication crashing when free fails , allow me exit way??
if heap corrupted, bets off. memory allocations may fail (unless they're on stack), might return pointers wacky areas, , existing stuff on heap mangled beyond recognition. in such cases, you're better off crashing, any action take (even trying gracefully exit) make things worse.
find code that's mangling stuff on heap, , fix or remove it.
Comments
Post a Comment