The C++ compiler will add its own statements to the destructor to destruct any member variables that are a class type.
Consider this:
class A {
public:
A() { m_szMessage = new char[10]; }
~A() { delete []m_szMessage; }
private:
char *m_szMessage;
};
class B {
public:
B() { }
~B() { }
private:
A m_clsA;
};
I suspect that you have a similar scenario where your stack trace was in
B::~B()
.
If the destructor to A is called twice, or by some other means the memory of A is deleted twice then the 2nd time it is deleted it will crash.
There are a number of other reasons that a program may crash when deleting memory too.
When in debug mode the compiler will check the heap around the allocated memory, and if you write 11 characters into the buffer of size 10 above then this would cause the debugger to break.