HEAP Debug Messages 
Author Message
 HEAP Debug Messages

Hello,

I'm developing a project using VC 6.0 and ATL under Windows 2000.  I was
debugging some new code recently and noticed some messages in the de{*filter*}'s
output window that are perplexing me.  The messages look something like the
following:

HEAP[Back.exe]: HEAP: Free Heap block d25050 modified at d25214 after it was
freed

I can consistenly make this message occur and it is occurring during a call
to the Win32 HeapFree function which is being called by the CRT free method.
It appears that during the process of freeing one heap block, another block
that was previously freed is being written to.

From my debugging, it seems that the data being written to the freed block
is always a 0x01 and that the freed block being violated always occurs
shortly before the block being freed in memory.

The errant write operations have not caused any detrimental side effects so
far, but I'm worried that they may.  If anyone has any experience with this
sort of heap behavior I would appeciate if you could give me any clues as to
what I am doing incorrectly.

Thanks,
Steve



Sat, 11 Oct 2003 07:29:56 GMT  
 HEAP Debug Messages

Quote:

> Hello,

> I'm developing a project using VC 6.0 and ATL under Windows 2000.  I was
> debugging some new code recently and noticed some messages in the de{*filter*}'s
> output window that are perplexing me.  The messages look something like the
> following:

> HEAP[Back.exe]: HEAP: Free Heap block d25050 modified at d25214 after it was
> freed

> I can consistenly make this message occur and it is occurring during a call
> to the Win32 HeapFree function which is being called by the CRT free method.
> It appears that during the process of freeing one heap block, another block
> that was previously freed is being written to.

> From my debugging, it seems that the data being written to the freed block
> is always a 0x01 and that the freed block being violated always occurs
> shortly before the block being freed in memory.

> The errant write operations have not caused any detrimental side effects so
> far, but I'm worried that they may.  If anyone has any experience with this
> sort of heap behavior I would appeciate if you could give me any clues as to
> what I am doing incorrectly.

> Thanks,
> Steve

It does not mean that "during the process of freeing one heap block,
another block
that was previously freed is being written to."  Rather, it is a
message from the debug checks built into the CRT that means "Hey,
somebody wrote to d25214 since the last time I checked it."  It is an
attempt to warn you of a bug in your program, of a sort that will
probably cause an access violation in a release build.  It happens
during a call to free simply because that's the only time the CRT gets
to check for things like this.   What you should do is try to figure
out which of your variables or arrays is at or closest to d25214.
Another good thing to do is find every 'delete' or 'free' in your
program and NULL the pointer variable after freeing it.  That makes
these suckers easier to find by making them write to 0 instead of
d25214.

--
Scott McPhillips [VC++ MVP]



Sat, 11 Oct 2003 09:05:56 GMT  
 HEAP Debug Messages
Scott,

Thanks for clearing up my confusion about what was actually happening in my
code.  It took an embarrassing long time, but I've finally pinpointed and
corrected the bug.  In my opinion, lifetime management is by far the most
difficult aspect of COM programming.  Thanks again.

Steve



Sun, 12 Oct 2003 01:23:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HEAP debug messages

2. HEAP debug message

3. HEAP debug message

4. incorrect debug heap messages in 4.2?

5. Heap Problems: Both Debug and non-Debug versions of CRT are active

6. HEAP[dllhost.exe]: HEAP: Free Heap block 1e32c28 modified at 1e32dc4 after it was freed

7. Debugging the C++ heap

8. Using the Debug Heap

9. How to turn off debug heap checking?

10. Debugging the heap

11. CRT heap, debug configurations, and WS2_32.DLL

12. Turn of debug info in heap

 

 
Powered by phpBB® Forum Software