On 11 Mar 2011, at 18:42, Quincey Morris wrote: > because you don't know whether the object will be deallocated immediately or > not. The Apple documentation says that it depends on what zone the object's > in. That means it isn't safe to CFRelease something (that you own) and then > CFRetain it again -- it may already be gone. However, let's assume it's in > the collector zone, so doesn't disappear immediately. Your bug is something > different. > > Whether the CF object got a CFRelease/CFRetain pair sometime before the crash > or not, your problem is that it needs: > > -- *either* to be CFRelease'd when its owner is done with it during the > normal course of business > -- *or* to be CFRRelease'd in the 'finalize' of the object that owns it > -- *or* to be CFMakeAllocatable'd after it was created** > > You owned it when you created it, but you apparently never balanced that with > a CFRelease/CFMakeAllocatable. If you wrote any other code that CFRetain'ed > it, of course, that code also needs to arrange for its own balancing > CFRelease. > > > ** Note that the CFRelease inside CFMakeAllocatable is safe, because > CFMakeAllocatable checks that the object is in the collector zone, and keeps > a temporary strong reference that prevents it from being collected before it > gets handed back to you. > > Thanks for taking the time to think about this Quincey. Unfortunately the bug has low repeatability (ie: I never see it).
I obtain my CF ref like so; SecKeychainRef keychainRef = nil; err = SecKeychainCopyDefault(&keychainRef); if (err != noErr) return nil; mySSLIdentity = [MGSSecurity findOrCreateSelfSignedIdentityInKeychain:keychainRef]; CFRelease(keychainRef); keychainRef only exists on the stack. So an explicit finalisation does not occur. keychainRef also has an initial retainCount of 2 (the framework recycles the same object I presume). I also tried to repeat the error in a GC test project. I generated large numbers of CF objects on the stack and either did not release them sufficiently or over retained them. Either way I could not trigger an auto_zone_resurrection_error(). So still stumped. Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.com _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
