• 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: Simple Out-of-Box Demo: Private Framework Crashes in 10.3.9
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Out-of-Box Demo: Private Framework Crashes in 10.3.9


  • Subject: Re: Simple Out-of-Box Demo: Private Framework Crashes in 10.3.9
  • From: Greg Parker <email@hidden>
  • Date: Tue, 25 Mar 2008 22:39:11 -0700

Jerry Krinock wrote:
Now, please understand that I'm not sure whether or not it's kosher to add +initialize in a category on a Cocoa class

Don't add +initialize in a category. The category's method will replace any present in the original class, which could break that class. However, I don't think that matters for NSString.



but the interesting thing is that when I run this in Leopard, seven classes (it's a "cluster", I suppose) are initialized without complaint...

When I run this in Panther, ten classes are initialized (looks like Apple has trimmed some of the fat since then), but in the first four of them, +initialize seems to run before there is an autorelease pool...

NSString (and most of the other toll-free bridged classes) is very special. CoreFoundation and the Objective-C runtime jump through hoops to make toll-free bridging work. The mechanisms used have changed in almost every Mac OS X release, so it's no surprise that you see different behavior on Panther and Leopard. And NSStrings are used very early, before main(), so it's also no surprise that there's no autorelease pool around yet.



http://www.cocoabuilder.com/archive/message/cocoa/2008/3/21/201996


I'm not convinced that your crash is caused by your category. Unfortunately, I have no sufficiently old ppc hardware handy to test any theories. You didn't post the full crash log, but it looks like the crash is a call to [@"name" copyWithZone:NULL]. If so, it dies because the string's isa pointer is NULL. The implementation of constant strings has changed in the past, so it could be that the binary built on Leopard doesn't match the constant string implementation on Panther.

What happens if you compile your code with -fno-constant-cfstrings?

What happens if you copy the contents +crashMe into - applicationDidFinishLaunching: , and omit the call to +crashMe completely?

What happens if you do the above, and also delete your NSString category?

What happens if you call `[@"name" copyWithZone:NULL]` directly, from either +crashMe or -applicationDidFinishLaunching:


-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: Simple Out-of-Box Demo: Private Framework Crashes in 10.3.9
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: Garbage collection - was Beginner with Cocoa
  • Next by Date: QTMovieLayer with QTMovie leaking memory
  • Previous by thread: Re: Simple Out-of-Box Demo: Private Framework Crashes in 10.3.9
  • Next by thread: Re: Simple Out-of-Box Demo: Private Framework Crashes in 10.3.9
  • Index(es):
    • Date
    • Thread