• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: alloc init thread safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alloc init thread safe?


  • Subject: Re: alloc init thread safe?
  • From: John Stiles <email@hidden>
  • Date: Thu, 8 Mar 2007 18:55:52 -0800

The worst part is, once you do have an app that's so big that you could benefit from ZeroLink, ZeroLink won't work with it anyway. Ironically, it is only remotely "stable" with small apps.


On Mar 8, 2007, at 5:44 PM, Rosyna wrote:

The first message to a Class is *not* threadsafe when ZeroLink is on. This is why the problem disappears in Release mode, because ZeroLink is always off in Release mode.



Everyone on this list should immediately do this in Xcode:

Switch to Debug/Development mode, go to the Build menu and make sure Allow ZeroLink is UNCHECKED.

ZeroLink offers no real benefits (especially to typical Cocoa developers that work with a relatively small number of files). And it causes random problems to appear like this one.

ZeroLink should always be off. It should never be turned on.

Ack, at 3/7/07, email@hidden said:

I have one object of Class1.  This object has a method

- (id) C2_alloc_init {
  return [[Class2 alloc] init];
}

This method can be called from multiple threads simultaneously. Sometimes this would return null, and it appears from the trace messages that this occurs when it is being called from two threads at about the same time. Both classes are subclasses of NSObject.

The problem seems to be solved by putting a lock around the alloc init calls, doing an unlock before returning the value.

So did I miss some documentation that says alloc init are not thread safe? Or at least alloc?

--


Sincerely, Rosyna Keller Technical Support/Carbon troll/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40blizzard.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >alloc init thread safe? (From: email@hidden)
 >Re: alloc init thread safe? (From: Rosyna <email@hidden>)

  • Prev by Date: Re: alloc init thread safe?
  • Next by Date: Re: alloc init thread safe?
  • Previous by thread: Re: alloc init thread safe?
  • Next by thread: Re: alloc init thread safe?
  • Index(es):
    • Date
    • Thread