On 12 Nov 2012, at 20:45, Greg Parker <gpar...@apple.com> wrote: > > > There is something special about statically-allocated memory. > Statically-allocated memory has always been zero for the life of the process. > Dynamically-allocated memory may have been non-zero at some point in the past > (i.e. if it was previously part of a now-freed allocation). > > The problem is your condition #2. If the memory was previously non-zero and > you set it to zero, you need appropriate memory barriers on some > architectures to prevent a race where the caller of dispatch_once() sees the > old non-zero value. Neither dispatch_once() nor the malloc system nor the > Objective-C runtime promise to provide the correct barriers. > > In some cases you might be able to add an appropriate memory barrier to your > -init... method, assuming that no calls to dispatch_once() occur before then. > > In practice this is a difficult race to hit, but it's not impossible. >
Sorry, I'm a bit late to the party here but I've just read this and I don't understand it. If this race condition really exists, you couldn't assume that *any* instance variables of a newly initialised object have been zeroed out. What am I missing? _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com