Annoying Debug error VS6 [BLOCKTYPE_IS_VALIID]

Started by
2 comments, last by ZQJ 18 years, 8 months ago
Annoying Debug error VS6 I have a pointer to an object created with new, in the class destructor I’m getting the following debug error when I hit the delete operator. Debug Assertion Failed! Dbgdel.cpp, line 47: Expression : BLOCKTYPE_IS_VALIID(pHead->nBlockUse)
CAsset_listNode::~CAsset_listNode()
{
	if(Asset_Asset!=NULL)
	{
		delete Asset_Asset;       // << HERE
		Asset_Asset = NULL;    
	}
}

Does any one have some quick tips? Before I post pages of code. Thanks [Edited by - bobason456 on August 15, 2005 3:16:28 AM]
Advertisement
Either:
  1. you have deleted an object twice, or
  2. Asset_Asset is not a valid pointer, or
  3. Asset_Asset was not allocated with new, or
  4. you have written data past the end of an allocation and have overwritten the allocator's bookkeeping information.
The problem is not necessarily in the class where the error occurred.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Thanks.. I've found the problem, but not solved it. It was a problem with just one of the many classes that was being pointed to by Asset_Asset.. Unfortunately I was using that class to test my asset management code.

Thanks for your help though..

Just out of interest though, incase it is the issue. What is “you have written data past the end of an allocation and have overwritten the allocator's bookkeeping information.”?
Memory allocators usually work by keeping a small amount of information at the start (and maybe end) of each block, such as block length and pointer to the previous block. This means when you do delete or free() it knows the range of memory you're giving up, plus it can combine that block with neighbouring blocks if they are also free. Incidentally I highly recommend Valgrind for catching this kind of error. Sadly it's only available for Linux though.

This topic is closed to new replies.

Advertisement