I have subclassed NSSearchField, implementing a method which appends a new 
search to recent searches after the user has entered text into it.  Three times 
during the last year, I’ve seen this method crash where it sets the new array 
of searches into super’s recentSearches,

[self setRecentSearches:recentSearches] ;

When I debug into that method, lldb tells me that both ‘self’ and 
‘recentSearches’ are valid objects, and that the latter is an __NSArrayM.  In 
other words, all looks OK.

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

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?)

When I debug into that NSNotificationCenter method, unfortunately lldb gives me 
the all-too-familiar “can’t read register" disappointment:

(lldb) po $rdi
error: Couldn't materialize: couldn't read the value of register rdi
Errored out in Execute, couldn't PrepareToExecuteJITExpression
(lldb) po $rdx
error: Couldn't materialize: couldn't read the value of register rdx
Errored out in Execute, couldn't PrepareToExecuteJITExpression
(lldb) po $rcx
error: Couldn't materialize: couldn't read the value of register rcx
Errored out in Execute, couldn't PrepareToExecuteJITExpression
(lldb) po $r8
error: Couldn't materialize: couldn't read the value of register r8
Errored out in Execute, couldn't PrepareToExecuteJITExpression
(lldb) po $r9
error: Couldn't materialize: couldn't read the value of register r9
Errored out in Execute, couldn't PrepareToExecuteJITExpression

I have searched my code thoroughly for anywhere that I am observing the 
‘recentSearches’ attribute of anything, but have found nothing.

Does anyone have any ideas?

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.

Thanks,

Jerry Krinock


_______________________________________________

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

Reply via email to