Re: Global destructors called for invalid objects on Darwin x86, but nowhere else.
Re: Global destructors called for invalid objects on Darwin x86, but nowhere else.
- Subject: Re: Global destructors called for invalid objects on Darwin x86, but nowhere else.
- From: "Kevin Harris" <email@hidden>
- Date: Wed, 12 Jul 2006 00:03:57 -0600
Thank you for replying so quickly.
On 7/11/06, Steve Checkoway <email@hidden> wrote:
C++ makes no guarantees as to the order that dtors are called. My guess
is that the CIMOMEnvironment has some global (probably singleton) class
and its dtor is being called before whatever is crashing. If this is the
case, you'll need to restructure your code in such a way as to avoid
this ordering dependency.
The CIMOMEnvironment is a reference counted pointer. I probably
should have mentioned that these globals are not referenced directly
by any other global variables in any other module. The
CIMOMEnvironment is accessed only through the use of a function (which
would allocate the environment upon first access), so the data
structure itself is not directly visible outside that particular
module.
> I don't believe there is a problem with the code, as this functions
> properly with several compilers on many platforms and only breaks on
> the x86 version of Darwin. The PPC version, with a much older xcode
> and gcc3.3, seems to work fine, so it could be a gcc4 issue. The PPC
> version also runs correctly with rosetta.
I seem to recall reading of other issues of this nature before. I think
that the x86 version calls the dtors in a different order than the ppc
version of g++.
That should be fine, as there isn't anything that depends on ordering
of construction or destruction. This also works fine on platforms
that aren't using g++ (among other platforms/compilers, HP-UX using
aCC).
> If anyone has any suggestions for things to check/fix, or could
> actually apply their uber Mac debugging skills, I would really
> appreciate it.
One idea is to reference count the global object and not to destroy it
until no other object is using it. Something like:
We are already doing that. The environment in this case is an
OpenWBEM IntrusiveReference, which is a form of reference counted
thread safe smart pointer.
The thing that I was finding most strange is that I put some constant
globals (something as simple as a string, or anything else that has a
non-trivial destructor) which are never referenced anywhere, and as
long as they were contained in one of the two files that I previously
mentioned, they would end up with their destructors called on what
appear to be invalid objects (not due to double destructor calls
either).
Thank you for your suggestions. I'll appreciate any more that you (or
anyone) has to offer.
-Kevin-
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden