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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eljay,

Thanks a lot for helping me!

This is also what I told the customer.

Actually, the C++ standard tells that the order of construction is the
order in which the global objects appear inside of a single translation
unit (a .cpp file). What is not sure is in which order global objects
coming from multiple source files (and therefore multiple object files)
are created (and then destructed!).

My basic question was more focused on asking if someone ever had such
problems with gcc showing that gcc 2.95.3 for solaris HAS A BUG IN THE
DESTRUCTOR CALLING MECHANISM FOR STATIC OBJECTS: actually I don't think
so! I suspect the code of the customer does exactly what you describe,
and that's why they incur in the problem.
Please give me only some other days to get an answer from them and
confirm you if this was the case.
Rgds,

Ogheri Alessandro
Senior Support AE
LDV Area
Cadence Design Systems GmbH
MozartStrasse 2 
85622 Feldkirchen
Tel +49 (0)89 4563 1866
Tel +49 (0)172 1404451
 


-----Original Message-----
From: Eljay Love-Jensen [mailto:eljay@xxxxxxxxx] 
Sent: Monday, September 22, 2003 1:35 PM
To: ogheri; gcc-help@xxxxxxx
Subject: Re: Need some help for troubles with the chain of destructors
called for static (global) objects in g++ 2.95.3 for solaris


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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux