Game Development Community

Fatal assertion in DEBUG mode

by Adam Johnston · in Torque Game Builder · 03/30/2006 (2:41 pm) · 2 replies

Hi there

I'm trying to implement a new class in C++
I was following the tutorial in TDN:
class t2dMyClass : public SimObject
{
   typedef SimObject Parent;

public:

	t2dMyClass ();
	bool onAdd();
	void onRemove();

	DECLARE_CONOBJECT(t2dMyClass);

	const char* generate (const S32 difficulty);

	~t2dMyClass();

private:
};

In release mode it was working so so (it's logic bugged)
when I changed to Debug mode the engine thrown a
fatal assertion in PlatformMemory.cc::1038

static void free(void* mem, bool array)
{
  ...
   AssertFatal(((bool)((hdr->flags & Array)==Array))==array, avar("Array alloc mismatch. "));
}

So I suspect something is wrong with my class.
I was thinking maybe delete is being called even if there are no object initialized?

Any ideas?

Thank you.

#1
03/30/2006 (3:16 pm)
I had this problem once and it turned out that I had allocated an array like this:
x = new y[123];

and than deallocated with delete x; instead of delete [] x;

-Michael
#2
03/30/2006 (3:35 pm)
Exactly Michael, thank you

I noticed I have new and delete code inside my class.
Also the destructor is being called at the start of the program
before any code, so I think is something performed by the macross of Torque.
and my destructor is deleting buffers that aren't allocated.