Need some help for troubles with the chain of destructors called for static (global) objects in g++ 2.95.3 for solaris

Eljay Love-Jensen eljay@adobe.com
Mon Sep 22 11:49:00 GMT 2003


Hi Ogheri,

My bet is that this is an order-of-destruction problem.  They usually occur when one static or global object refers to and relies upon another static or global object during its destruction (as the program is shutting down), but the other object has already been destructed.

If that is the problem, to solve order-of-destruction problems, interrelationships between global objects needs to be scrutinized.  Keep in mind, order of construction and order of destruction is not something to rely upon in C or C++!  One way that worked for me to get rid of all order-of-destruction problems was to eliminate ALL global objects (global "plain old data" types are usually okay... but I got rid of them too).  Another way to help track down order-of-destruction issues is to make sure each object sets all it's data members to some known garbage value (don't use memset ... set each field explicitly).

Of course, you'll need the source code to effect these kinds of changes.

HTH,
--Eljay




More information about the Gcc-help mailing list