[haiku-development] Re: Static object Destructor

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 24 Jul 2015 10:11:24 +0200

Am 24/07/2015 um 07:57 schrieb Pete Goodeve:

The first thing I wanted to look at was annoying crash when one
quits Sequitur. Turn out that this is due to a static object that has
a destructor called on quitting. This wants to delete some BBitmaps,
but the debugger is called because "You need to have a valid app_server
connection first!". Obviously there *was* an app_server connection,
because it was doing everything right before, bu I guess (in Haiku) it
is broken before the destructor gets called. (Worked fine in BeOS,
naturally.)

IIRC BeOS never called the static destructors on quit.
In any case, having static objects is problematic, as the order in which they are destructed is non-deterministic.

I've hacked in a fix, by calling the guts of the destructor in QuitRequested,
but I'd be interested to know if this is a fundamental difference in Haiku.
Still using gcc 2.95, so that can't be factor.

I'd be glad to know if this should be "corrected", or if I should live with the
hack.

Since the BApplication is already gone when the static objects are destructed, the code in Sequitur is just buggy, and should be fixed.

Probably the easiest way would be to make that object a pointer, and define its lifetime as needed manually (ie. by creating/deleting it as and when needed).

Bye,
Axel.


Other related posts: