I'm working on a project which uses gtk+ and gtkmm. We use them in preference to MFC because the program needs to be cross-platform. For quite a long time, customers on OS-X and Linux have sometimes complained that the program would crash during shutdown but the Windows version (which I work on) never seemed to suffer. However, I'm now transferring my build environment to a new PC and I'm noticing the same shutdown crashes. It's a bit complicated so let me start with a small example:-

Code:
namespace Whatever {

class B {
public:
	virtual ~B();

private:
	int bb;
};

class A : public B {
public:
	virtual ~A();

private:
	int aa;
};

B::~B()
{
	bb = 0; // <--- Breakpoint #3 here
}

A::~A()
{
	aa = 0; // <--- Breakpoint #2 here
}

} /* namespace Whatever */

int main (int argc, char *argv[])
{
	Whatever::A* pA = new Whatever::A;
	delete pA; // <--- Breakpoint #1 here

	return 0;
}
Suppose I run the above program. When it stops at breakpoint #1 I make a note of the value of pA. Eventually the program reaches breakpoints #2 and #3. At each point my this pointer is exactly the same number. If the value of pA was 0x03604fb0, my this pointer is identical at both stages.

Now let's consider the real example:-

Code:
namespace Gtk {

class Widget {
public:
  virtual ~Widget() {}
};

class Container : public Widget {
public:
  virtual ~Container() {}
};

class Bin : public Container {
public:
	virtual ~Bin() {}
};

class Window : public Bin {
public:
	virtual ~Window();

protected:
	void destroy_();
};

Window::~Window()
{
  destroy_(); // <--- Breakpoint #2 here
}

} /* namespace Gtk */

int main (int argc, char *argv[])
{
	Gtk::Window* pW = new Gtk::Window;
	delete pW; // <--- Breakpoint #1 here

	return 0;
}
Suppose I run the real example. At breakpoint #1 the value of pW is 0x03604fb0. But by the time I reach breakpoint #2 my this point is slightly different:- 0x03604fcc. Can anyone think of a reason for this behaviour? It doesn't seem right to me and I'm wondering if it might be contributing to our shutdown crashes