Re: Global destructors called for invalid objects on Darwin x86, but nowhere else.
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HvD42LiI4PotZTs4L8p2btRR4sLgZoS4ptQwfpIzDMDmRp4fGPXRTfby1qhZzNLkMgMUgX9E5Yqgp/cf3Yd8utSUefA/e58wh9EaoPNRsss02Q2d6mKU1ziVOTbxhl8hz5F69zg1cfEpgmbYJOI+HWTUVWjweORW5+zWW63TbGc= Thank you for replying so quickly. 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On 7/11/06, Steve Checkoway <steve@cs.washington.edu> wrote: This email sent to site_archiver@lists.apple.com
participants (1)
-
Kevin Harris