I use NSTextView in my app, and I am getting a LOT of crashes when I’m running the app with the debugger attached, and it all points to this spell checker in NSTextView. The crash happens as soon as the textview shows the ‘word completion’ option. If I turn off the “Continuous Spell Checking” option, it works fine, and it doesn’t crash.
The exception reason given is: __NSCFString * "NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds"
This is what the stack trace looks like in Xcode:
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x000000018335eb38 in objc_exception_throw ()
#1 0x0000000184e01910 in -[NSRLEArray objectAtIndex:effectiveRange:] ()
#2 0x0000000184e519a8 in -[NSMutableAttributedString addAttribute:value:range:] ()
#3 0x000000018818086c in -[NSText(NSTextAccessibilityPrivate) accessibilityAXAttributedStringForCharacterRange:parent:] ()
#4 0x0000000187f576b0 in -[NSAccessibilityAttributeAccessorInfo getParameterizedAttributeValue:forObject:withParameter:] ()
#5 0x0000000187f591a8 in ___NSAccessibilityEntryPointValueForAttributeWithParameter_block_invoke.799 ()
#6 0x0000000187f5458c in NSAccessibilityPerformEntryPointObject ()
#7 0x0000000187f56190 in NSAccessibilityEntryPointValueForAttributeWithParameter ()
#8 0x0000000187cb6a3c in CopyParameterizedAttributeValue ()
#9 0x00000002327057ac in ___lldb_unnamed_symbol4511 ()
#10 0x0000000232705854 in ___lldb_unnamed_symbol4512 ()
#11 0x000000018a5b3670 in _AXXMIGCopyParameterizedAttributeValue ()
#12 0x000000018a5d4894 in _XCopyParameterizedAttributeValue ()
#13 0x000000018a592ff8 in mshMIGPerform ()
#14 0x000000018382a250 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#15 0x000000018382a178 in __CFRunLoopDoSource1 ()
#16 0x0000000183828b78 in __CFRunLoopRun ()
#17 0x0000000183827c58 in CFRunLoopRunSpecific ()
#18 0x000000018f2bc27c in RunCurrentEventLoopInMode ()
#19 0x000000018f2bf4e8 in ReceiveNextEventCommon ()
#20 0x000000018f44a484 in _BlockUntilNextEventMatchingListInModeWithFilter ()
#21 0x000000018774fab4 in _DPSNextEvent ()
#22 0x00000001880ee5b0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#23 0x00000001884b836c in -[NSCorrectionPanel _interceptEvents] ()
#24 0x00000001884b8f30 in -[NSCorrectionPanel showPanelAtRect:inView:primaryString:alternativeStrings:forType:completionHandler:] ()
#25 0x00000001880c91ec in -[NSSpellChecker showCorrectionIndicatorOfType:range:primaryString:alternativeStrings:forStringInRect:view:completionHandler:] ()
#26 0x00000001880ca0c0 in -[NSSpellChecker _showInlinePredictionForReplacingRange:markedRange:string:withString:view:client:lastReplacementRange:completeWordIndexes:resultDictionary:completionHandler:] ()
#27 0x00000001880cb26c in -[NSSpellChecker showCompletionForCandidate:selectedRange:offset:inString:rect:view:client:completionHandler:] ()
#28 0x0000000188303a94 in -[NSTextCheckingController handleCompletionFromCandidates:forSelectedRange:offset:inAnnotatedString:rect:view:] ()
#29 0x00000001882f9054 in -[NSTextCheckingController viewForRange:completionHandler:] ()
#30 0x00000001883041c8 in __60-[NSTextCheckingController handleCandidates:sequenceNumber:]_block_invoke ()
#31 0x000000018789105c in -[NSTextCheckingController annotatedSubstringForProposedRange:wrap:completionHandler:failureHandler:] ()
#32 0x0000000187890da4 in -[NSTextCheckingController annotatedSubstringForProposedRange:completionHandler:] ()
#33 0x00000001878927d4 in -[NSTextCheckingController annotatedSubstringForSelectedRangeWithCompletionHandler:] ()
#34 0x0000000188304134 in -[NSTextCheckingController handleCandidates:sequenceNumber:] ()
#35 0x00000001883067e0 in ___NSRunLoopTimerCreateWithHandler_block_invoke ()
#36 0x0000000183842e14 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#37 0x0000000183842ad4 in __CFRunLoopDoTimer ()
#38 0x0000000183842610 in __CFRunLoopDoTimers ()
#39 0x0000000183828a18 in __CFRunLoopRun ()
#40 0x0000000183827c58 in CFRunLoopRunSpecific ()
#41 0x000000018f2bc27c in RunCurrentEventLoopInMode ()
#42 0x000000018f2bf4e8 in ReceiveNextEventCommon ()
#43 0x000000018f44a484 in _BlockUntilNextEventMatchingListInModeWithFilter ()
#44 0x000000018774fab4 in _DPSNextEvent ()
#45 0x00000001880ee5b0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#46 0x0000000187742c64 in -[NSApplication run] ()
#47 0x000000018771935c in NSApplicationMain ()
If I run the debug version of the app without the debugger, it works fine as well. In fact, if I run the app without "All Objective-C Exceptions" breakpoint, it also works fine. So it seems like some framework issue, which is making it hard to run and test my app.
What’s the reason for this, and is this an issue I should be worried about for when the app is available to my users?