Re: Sudden and hard to reproduce crashes in libcache
Re: Sudden and hard to reproduce crashes in libcache
- Subject: Re: Sudden and hard to reproduce crashes in libcache
- From: Dragan Milić <email@hidden>
- Date: Tue, 13 Mar 2012 09:55:08 +0000
Just an update on this issue:
On čet 23.02.2012., at 20.00, Greg Parker wrote:
> Yep, that's CFRelease(NULL), plus ExceptionHandling.framework catching the Unix signal and trying to turn it into an Objective-C exception.
>
> That background thread is part of NSCache. This could be a bug in your use of NSCache, a memory smasher somewhere, or a bug in NSCache itself.
>
> You may be able to reproduce this by forcing the app into a low memory situation. That background thread is evicting NSCache contents in responds to low memory. Once you can reproduce, you should try zombies and guard malloc.
Apparently, it's a bug in NSCache. On http://files.me.com/milke/t5ufx5 can you find a super simple sample app to reproduce it every time without any problem. It looks like -[NSString stringWithFormat:] (and possibly other calls) can return the same pointer rather than creating new object every call. Perhaps it's trying to reuse strings to save memory? NSCache seems not to like that and crashes. If I wrap the strings in a simple holder object, which has nothing more than a string as it's content ivar, that solves the crashing problem. But it's still completely incorrect behaviour on NSCache part.
I think this makes NSCache (at the moment) almost unusable in real world applications, because you never now whether and when it's going to crash. Maybe never, maybe immediately. I encourage everyone (especially those using NSCache) to file a bug report to Apple. If they get a lot of duplicates on the same issue, they may hopefully do something quicker. NSCache was introduced for object caching and memory saving and having to wrap every cached object in a holder object defies cache's purpose (kind of).
-- Dragan
_______________________________________________
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