Re: Weird crash in -[NSSearchField setRecentSearches:]
Re: Weird crash in -[NSSearchField setRecentSearches:]
- Subject: Re: Weird crash in -[NSSearchField setRecentSearches:]
- From: Quincey Morris <email@hidden>
- Date: Tue, 04 Nov 2014 06:33:59 +0000
On Nov 3, 2014, at 19:54 , Jerry Krinock <email@hidden> wrote:
>
> The highest line in the stack in my code is #12. Line #11 indicates that the crash occurs when AppKit attempts to post a notification, which I suspect is a KVO notification. (But is NSNotificationCenter used in KVO?)
No, it is not. The fact that NSNotificationCenter is involved tells you that this is *not* KVO related.
> The ‘recentSearches’ setter and getter have been available in the superclass NSSearchField since Mac OS X 10.3. One weird thing is that when I option-click on -setRecentSearches: in Xcode, it gives me the Swift declaration and says that it is available in OS X 10.10 or later. I don’t see any other methods behaving like that.
This may be a red herring. Some declarations that were in getter/setter form originally were migrated to @property form (to help Swift convert Obj-C headers automatically) and that seems to have affected the availability macros. Conversely, some getter/setter declaration forms are now marked as deprecated when the methods are un-deprecated, because the SDK definition is now via @property.
> Here is the call stack:
>
> #0 in strlen ()
> #1 in strdup ()
> #2 in objc_class::nameForLogging() ()
> #3 in cache_t::bad_cache(objc_object*, objc_selector*, objc_class*) ()
> #4 in objc_msgSend_corrupt_cache_error ()
> #5 in safeARCWeaklyStore ()
> #6 in -[NSMenuItem setTarget:] ()
> #7 in -[NSMenuItem copyWithZone:] ()
> #8 in -[NSSearchFieldCell(NSSearchFieldCell_Local) _updateSearchMenu] ()
> #9 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
> #10 in _CFXNotificationPost ()
> #11 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
> #12 in -[SSYSearchField appendToRecentSearches:] at SSYSearchField.m:53
> #13 in -[CntntViewController search:] at /CntntViewController.m:351
> #14 in -[BkmxDocWinCon search:] at BkmxDocWinCon.m:2907
Personally, I’d worry about entry #4. Surely ‘objc_msgSend_corrupt_cache_error’ has got to be very, very bad.
Taking a wild guess, I’d propose that you have a thread safety issue. Either the above call stack is not on the main thread but should be, or something else is thread-unsafe and interacting badly with this code. (That could account for the crash being very rare.)
Since you use KVO quite a bit (though not for this), you might for example be getting some KVO notification on a background thread that leads to code that requires the main thread but isn’t on it.
Or you could just have a random memory write that only occasionally clobbers the method dispatch caches.
Or it could also be any kind of memory management error, but that doesn’t tend to corrupt method dispatch caches.
_______________________________________________
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