By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,903 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,903 IT Pros & Developers. It's quick & easy.

_BLOCK_TYPE_IS_VALID - 'by value' destruction problem

P: 7
Im using vc++ 2005 express and while running a program i get an assertion failure and the debugger breaks at the indicated line of code with the message:


indicating a corrupted heap apparently

from what ive read, this is a problem with deleting a pointer more than once, or perhaps deleting a pointer that points somewhere unexpected and not "owned" by the object calling the delete on that pointer

I just solved the problem by ensuring i had copy constructors and operator= defined for all objects that were being passed 'by value' in my program as well as those objects i put into STL containers, i thought i might leave this up here incase someone else comes across the same error.

and since ive already got this post up here (rather than bumping the original), i wanted to say thanks to weaknessforcats for the help previously with the visitor pattern, i used those references you provided and came up with a scaled down version of it that worked perfectly :D

-rest of code and problem deleted-
May 24 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
Yes, that is the heap memory corruption signal.

You are correct that is cause by overrunning your allocation or deleting it more than once.

You might look at my article on Handle classes in the C++ Atricles. A Handle is an alternative to making a copy of an object where all you really need is the address.

I'm glad the Visitor worked out.
May 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.