mfc >> Free Heap Block Modified

by Michael Tissington » Sat, 29 Nov 2003 08:56:19 GMT

I'm going crazy trying to track down an error

This is the stack when I get a Free Heap Block modified error.

Any ideas how to track it down please?

NTDLL! 77f9d959()
NTDLL! 77f83eb1()
NTDLL! 77f589f2()
_heap_alloc_base(unsigned int 0x00000230) line 200
_heap_alloc_dbg(unsigned int 0x00000200, int 0x00000001, const char *
0x00000000, int 0x00000000) line 378 + 9 bytes
_nh_malloc_dbg(unsigned int 0x00000200, int 0x00000000, int 0x00000001,
const char * 0x00000000, int 0x00000000) line 248 + 21 bytes
malloc(unsigned int 0x00000200) line 130 + 21 bytes
AfxUnlockTempMaps(int 0xffffffff) line 75 + 16 bytes
DllMain(HINSTANCE__ * 0x039a0000, unsigned long 0x00000003, void *
0x00000000) line 172
_DllMainCRTStartup(void * 0x039a0000, unsigned long 0x00000003, void *
0x00000000) line 273 + 17 bytes
NTDLL! 77f5b42c()
NTDLL! 77f629df()
KERNEL32! 77e74acd()
KERNEL32! 77e7346e()

--
Michael Tissington
http://www.tabtag.com
http://www.oaklodge.com





mfc >> Free Heap Block Modified

by Scott McPhillips [MVP] » Sat, 29 Nov 2003 12:03:50 GMT





The stack doesn't matter in this case. All memory allocations/frees
check the heap validity. The error means that you modified memory that
wasn't yours at some earlier time, after the previous memory allocator
call and before the one that discovered the error. Temporarily
sprinkle calls to _CrtCheckMemory() around in your program. That will
let you detect the error much closer to the source. The source will be
a write that is using an invalid pointer or index. Another way to track
it down is to initialize every pointer to NULL, and set every pointer
that you delete to NULL. That will give you an instant error message
when you use an invalid pointer.

--
Scott McPhillips [VC++ MVP]




mfc >> Free Heap Block Modified

by xmontyx » Sat, 29 Nov 2003 17:56:32 GMT

have you checked all the delete statements ,
this sort of thing happened to me once and i was deleting an already
deleted memoryblock in a destructor




Free Heap Block Modified

by Stephen Kellett » Sat, 29 Nov 2003 20:19:55 GMT

In message < XXXX@XXXXX.COM >, Michael Tissington
< XXXX@XXXXX.COM > writes

Try a commercial software tool.
Memory Validator. 30 day evaluation.

http://www.softwareverify.com

Look at the tutorials (on the help menu). Memory Validator has built in
support for identifying deleting an already deleted memory block.

If you need help email support.

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk
RSI Information: http://www.objmedia.demon.co.uk/rsi.html


Free Heap Block Modified

by Michael Tissington » Sun, 30 Nov 2003 12:03:36 GMT

Thanks.

--
Michael Tissington
http://www.tabtag.com
http://www.oaklodge.com









Similar Threads

1. HEAP: free heap block modified after it was freed

2. Crash: HEAP: Free Heap block modified...

Dear Programmers

I have the following problem:
I continue the programming-work of somebody else.
Now I get the following error:

HEAP[goodTime.exe]: HEAP: Free Heap block cfd8dd0 modified at cfd8e6c
after it was freed

(UserBreak)

1) How can I prevent this user-break?
2) How would you look for the reason for this error?

The Call-Stack doesn't tell me a lot...:

NTDLL! 77f9193c()
NTDLL! 77f9c73e()
NTDLL! 77fb064e()
NTDLL! 77f9bd5a()
NTDLL! 77fcb63e()
_heap_alloc_base(unsigned int 112) line 200
_heap_alloc_dbg(unsigned int 68, int 1, const char * 0x5f4d096c
THIS_FILE, int 72) line 378 + 9 bytes
_nh_malloc_dbg(unsigned int 68, int 0, int 1, const char * 0x5f4d096c
THIS_FILE, int 72) line 248 + 21 bytes
_malloc_dbg(unsigned int 68, int 1, const char * 0x5f4d096c THIS_FILE,
int 72) line 165 + 27 bytes
operator new(unsigned int 68, int 1, const char * 0x5f4d096c
THIS_FILE, int 72) line 373 + 22 bytes
operator new(unsigned int 68, const char * 0x5f4d096c THIS_FILE, int
72) line 65 + 19 bytes
CMapPtrToPtr::InitHashTable(unsigned int 17, int 1) line 72 + 19 bytes
CMapPtrToPtr::operator[](void * 0x01010057) line 222
CHandleMap::SetPermanent(void * 0x01010057, CObject * 0x0012f804
{hDC=0x01010057 attrib=0x00000000}) line 183 + 12 bytes
CDC::Attach(HDC__ * 0x01010057) line 118
CWindowDC::CWindowDC(CWnd * 0x0cfd6d08 {CDockBar hWnd=0x0047086e})
line 1013 + 36 bytes
CControlBar::EraseNonClient() line 601 + 12 bytes
CDockBar::OnNcPaint() line 595
CWnd::OnWndMsg(unsigned int 133, unsigned int 2097417450, long 0, long
* 0x0012f954) line 1836
CWnd::WindowProc(unsigned int 133, unsigned int 2097417450, long 0)
line 1596 + 30 bytes
CControlBar::WindowProc(unsigned int 133, unsigned int 2097417450,
long 0) line 480 + 20 bytes
AfxCallWndProc(CWnd * 0x0cfd6d08 {CDockBar hWnd=0x0047086e}, HWND__ *
0x0047086e, unsigned int 133, unsigned int 2097417450, long 0) line
215 + 26 bytes
AfxWndProc(HWND__ * 0x0047086e, unsigned int 133, unsigned int
2097417450, long 0) line 379
AfxWndProcBase(HWND__ * 0x0047086e, unsigned int 133, unsigned int
2097417450, long 0) line 220 + 21 bytes
USER32! 77e4158f()
USER32! 77e3c19d()
USER32! 77e3c1ca()
NTDLL! 77f91baf()
CDockBar::OnPaint() line 605 + 12 bytes
CWnd::OnWndMsg(unsigned int 15, unsigned int 0, long 0, long *
0x0012fc8c) line 1836
CWnd::WindowProc(unsigned int 15, unsigned int 0, long 0) line 1596 +
30 bytes
CControlBar::WindowProc(unsigned int 15, unsigned int 0, long 0) line
480 + 20 bytes
AfxCallWndProc(CWnd * 0x0cfd6d08 {CDockBar hWnd=0x0047086e}, HWND__ *
0x0047086e, unsigned int 15, unsigned int 0, long 0) line 215 + 26
bytes
AfxWndProc(HWND__ * 0x0047086e, unsigned int 15, unsigned int 0, long
0) line 379
AfxWndProcBase(HWND__ * 0x0047086e, unsigned int 15, unsigned int 0,
long 0) line 220 + 21 bytes
USER32! 77e4158f()
USER32! 77e3c19d()
USER32! 77e3c1ca()
NTDLL! 77f91baf()
USER32! 77e27ed6()
CWinThread::Run() line 487 + 11 bytes
CWinApp::Run() line 400
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char *
0x00134976, int 1) line 49 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char *
0x00134976, int 1) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 7c5989a5()

Pascal

3. Free: Heap block modified after it was freed