Sign in to follow this  
ehmdjii

how to debug a heap error

Recommended Posts

ehmdjii    238
hello, in some cases i get a heap error in my application. HEAP[proh.exe]: HEAP: Free Heap block 3ff92d0 modified at 3ff92f8 after it was freed Unhandled exception at 0x7c911230 in proh.exe: User breakpoint. (what exactly does that error mean, btw? ) using the debug mode and the stack frame i can find the line, that causes it:
...
Entry * e = m_data[key % m_capacity]; //get access from hashtable
...
delete e; //heap error happens here
...

but i don't see anything wrong here. so what could cause the heap error?

Share this post


Link to post
Share on other sites
dave    2187
You appear to be deleting a pointer that isn't pointing to anything on the heap. It is pointing at a stack variable.

Since you havn't posted much code and i don't know how you are creating your hashtable then i'm just guessing.

You can only delete things that are created with 'new'.

Hope that helps,

ace

Share this post


Link to post
Share on other sites
SiCrane    11839
That error means that on the delete call the debug runtime did a heap consistency check and found a place where you wrote to memory your free somewhere else. Basically you used a pointer after you freed or deleted it or you have a really bad pointer indirection or array index use somewhere. The write to freed memory probably happened somewhere between the last time you used new or delete and the call to delete you just did.

Share this post


Link to post
Share on other sites
SiCrane    11839
Quote:
Original post by ace_lovegrove
You appear to be deleting a pointer that isn't pointing to anything on the heap. It is pointing at a stack variable.


Deleting a pointer to the stack gives a different runtime error. Something like Invalid Address specified to RtlValidateHeap( blah blah blah ), depending on which version of the runtime you're using.

Share this post


Link to post
Share on other sites
ehmdjii    238
thank you guys!

it's probably the missing "new".

unfortunately this is not my code, but i will report it to the responsible guy tomorrow. :-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this