I notice that in my app's crash log on OS X that one of the first sections is "Application Specific Backtrace". It shows something like this:
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff8acef716 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8d723470 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ad7df07 -[__NSDictionaryM setObject:forKey:] + 135
3 My App 0x00000001030c6f72 My App + 81778
4 My App 0x00000001030c7969 My App + 84329
5 AppKit 0x00007fff8c3d5afa -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1012
6 AppKit 0x00007fff8c5ec1d6 -[NSNib _instantiateNibWithExternalNameTable:] + 610
7 AppKit 0x00007fff8c5ebf43 -[NSNib instantiateNibWithOwner:topLevelObjects:] + 254
8 AppKit 0x00007fff8c5eb4f7 -[NSViewController loadView] + 184
9 AppKit 0x00007fff8c593349 -[NSViewController view] + 41
10 My App 0x00000001030cae69 My App + 97897
11 My App 0x00000001030cbb3a My App + 101178
12 AppKit 0x00007fff8c590322 -[NSTableView _sendDelegateHeightOfRow:] + 130
13 AppKit 0x00007fff8c5900db -[NSTableView _uncachedRectHeightOfRow:] + 197
14 AppKit 0x00007fff8c58ff2c -[_NSTableRowHeightStorage _cacheRowHeights] + 163
15 AppKit 0x00007fff8c54a6f5 -[_NSTableRowHeightStorage _ensureRowHeights] + 80
16 AppKit 0x00007fff8c5680cb -[_NSTableRowHeightStorage computeRowAtPoint:] + 38
17 AppKit 0x00007fff8c567fd9 -[NSTableView rowAtPoint:] + 306
18 AppKit 0x00007fff8c566af7 -[NSTableView rowsInRect:] + 375
19 AppKit 0x00007fff8c597ca4 _NSTVVisibleRowsForUpdate + 673
20 AppKit 0x00007fff8c5971e5 -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 96
21 AppKit 0x00007fff8c597001 -[NSTableRowData updateVisibleRowViews] + 119
22 AppKit 0x00007fff8c56f0fb -[NSTableView viewWillDraw] + 165
23 AppKit 0x00007fff8c44cbed __22-[NSView viewWillDraw]_block_invoke_0 + 307
24 CoreFoundation 0x00007fff8ace80b6 __NSArrayEnumerate + 582
25 AppKit 0x00007fff8c44c92d -[NSView viewWillDraw] + 244
26 AppKit 0x00007fff8c44bf84 -[NSView _sendViewWillDrawInRect:clipRootView:] + 1525
27 AppKit 0x00007fff8c4183f1 -[NSView displayIfNeeded] + 1044
28 AppKit 0x00007fff8c4c429e -[NSClipView _immediateScrollToPoint:] + 7852
29 AppKit 0x00007fff8c4c2342 -[NSClipView scrollToPoint:] + 268
30 AppKit 0x00007fff8c58acdd -[NSScrollView scrollClipView:toPoint:] + 426
31 AppKit 0x00007fff8c4c20cc -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1626
32 AppKit 0x00007fff8c39d579 -[NSClipView _scrollTo:animate:] + 28
33 AppKit 0x00007fff8caab2a1 __31-[NSScrollView _snapRubberBand]_block_invoke_0610 + 1989
34 AppKit 0x00007fff8ca2412a ____NSPeriodicInvokerScheduled_block_invoke_0 + 57
35 libdispatch.dylib 0x00007fff8a013f3d _dispatch_call_block_and_release + 15
36 libdispatch.dylib 0x00007fff8a0100fa _dispatch_client_callout + 8
37 libdispatch.dylib 0x00007fff8a0149ab _dispatch_after_timer_callback + 22
38 libdispatch.dylib 0x00007fff8a0100fa _dispatch_client_callout + 8
39 libdispatch.dylib 0x00007fff8a0122d7 _dispatch_source_invoke + 691
40 libdispatch.dylib 0x00007fff8a011349 _dispatch_queue_invoke + 72
41 libdispatch.dylib 0x00007fff8a0150cd _dispatch_main_queue_callback_4CF + 220
42 CoreFoundation 0x00007fff8ac9181e __CFRunLoopRun + 1614
43 CoreFoundation 0x00007fff8ac90dd2 CFRunLoopRunSpecific + 290
44 HIToolbox 0x00007fff85323774 RunCurrentEventLoopInMode + 209
45 HIToolbox 0x00007fff85323512 ReceiveNextEventCommon + 356
46 HIToolbox 0x00007fff853233a3 BlockUntilNextEventMatchingListInMode + 62
47 AppKit 0x00007fff8c414fa3 _DPSNextEvent + 685
48 AppKit 0x00007fff8c414862 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
49 AppKit 0x00007fff8c40bc03 -[NSApplication run] + 517
50 AppKit 0x00007fff8c3b0656 NSApplicationMain + 869
51 My App 0x00000001030b4554 My App + 5460
52 ??? 0x0000000000000002 0x0 + 2
I know that's code that was running on the main thread, but yet it's shown in that section and NOT in the Thread 0 backtrace, which looks something like this:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8588d212 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff8e1fab34 pthread_kill + 90
2 libsystem_c.dylib 0x00007fff8e23edfa abort + 143
3 libc++abi.dylib 0x00007fff888abf87 abort_message + 257
4 libc++abi.dylib 0x00007fff888a9936 default_terminate() + 28
5 libobjc.A.dylib 0x00007fff8d7238f3 _objc_terminate() + 91
6 libc++.1.dylib 0x00007fff8694c8fe std::terminate() + 20
7 libobjc.A.dylib 0x00007fff8d72365e objc_terminate + 9
8 libdispatch.dylib 0x00007fff8a01010e _dispatch_client_callout + 28
9 libdispatch.dylib 0x00007fff8a0149ab _dispatch_after_timer_callback + 22
10 libdispatch.dylib 0x00007fff8a0100fa _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff8a0122d7 _dispatch_source_invoke + 691
12 libdispatch.dylib 0x00007fff8a011349 _dispatch_queue_invoke + 72
13 libdispatch.dylib 0x00007fff8a0150cd _dispatch_main_queue_callback_4CF + 220
14 com.apple.CoreFoundation 0x00007fff8ac9181e __CFRunLoopRun + 1614
15 com.apple.CoreFoundation 0x00007fff8ac90dd2 CFRunLoopRunSpecific + 290
16 com.apple.HIToolbox 0x00007fff85323774 RunCurrentEventLoopInMode + 209
17 com.apple.HIToolbox 0x00007fff85323512 ReceiveNextEventCommon + 356
18 com.apple.HIToolbox 0x00007fff853233a3 BlockUntilNextEventMatchingListInMode + 62
19 com.apple.AppKit 0x00007fff8c414fa3 _DPSNextEvent + 685
20 com.apple.AppKit 0x00007fff8c414862 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
21 com.apple.AppKit 0x00007fff8c40bc03 -[NSApplication run] + 517
22 com.apple.AppKit 0x00007fff8c3b0656 NSApplicationMain + 869
23 com.mycompany.myapp 0x00000001030b4554 0x1030b3000 + 5460
What's the significance of "Application Specific Backtrace" and why isn't that code included in the main thread backtrace?
(To be clear, I'm not asking how to debug this code, I'm just looking for an explanation on the structure and meaning of the crash log itself. Thanks!)
This is how exception handling works. You have an exception on the main thread, where the NSException is created (it holds all info about exception including current stack trace). After throwing an exception object control is passed to the closest handler in the call stack, unwinding the stack between throw and catch point. If an exception is not caught, it is intercepted by a function called the uncaught exception handler. The uncaught exception handler always causes the program to exit but may perform some task before this happens.
The default uncaught exception handler logs a message to the console before it exits the program.
So in your case Application Specific Backtrace is the stacktrace when exception was thrown and Thread 0 Crashed:: Dispatch queue: com.apple.main-thread is the stack trace when the app was killed.
Notice that up to this point the stack trace is identical:
10 libdispatch.dylib 0x00007fff8a0100fa _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff8a0122d7 _dispatch_source_invoke + 691
12 libdispatch.dylib 0x00007fff8a011349 _dispatch_queue_invoke + 72
13 libdispatch.dylib 0x00007fff8a0150cd _dispatch_main_queue_callback_4CF + 220
14 com.apple.CoreFoundation 0x00007fff8ac9181e __CFRunLoopRun + 1614
15 com.apple.CoreFoundation 0x00007fff8ac90dd2 CFRunLoopRunSpecific + 290
16 com.apple.HIToolbox 0x00007fff85323774 RunCurrentEventLoopInMode + 209
17 com.apple.HIToolbox 0x00007fff85323512 ReceiveNextEventCommon + 356
18 com.apple.HIToolbox 0x00007fff853233a3 BlockUntilNextEventMatchingListInMode + 62
19 com.apple.AppKit 0x00007fff8c414fa3 _DPSNextEvent + 685
20 com.apple.AppKit 0x00007fff8c414862 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
21 com.apple.AppKit 0x00007fff8c40bc03 -[NSApplication run] + 517
22 com.apple.AppKit 0x00007fff8c3b0656 NSApplicationMain + 869
Related
So I was messing around with the Document Based Application, and I'm trying get the save file to work. I have a file format save to .lgre and whenever I hit save, I'll select location, and then nothing happens except that I get this in that console. Can someone tell me whats going wrong?
0 CoreFoundation 0x00007fff8c64b64c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8e9ca6de objc_exception_throw + 43
2 CoreFoundation 0x00007fff8c64b4fd +[NSException raise:format:] + 205
3 Ligre UI 0x00000001000011b1 -[Document dataOfType:error:] + 129
4 AppKit 0x00007fff933d8fcf -[NSDocument writeToURL:ofType:error:] + 861
5 AppKit 0x00007fff933dbf03 -[NSDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] + 494
6 AppKit 0x00007fff933dae6b -[NSDocument _writeSafelyToURL:ofType:forSaveOperation:forceTemporaryDirectory:error:] + 850
7 AppKit 0x00007fff933dbb93 -[NSDocument _writeSafelyToURL:ofType:forSaveOperation:error:] + 28
8 AppKit 0x00007fff933dbd01 -[NSDocument writeSafelyToURL:ofType:forSaveOperation:error:] + 357
9 AppKit 0x00007fff933e8fc5 __66-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_22307 + 240
10 AppKit 0x00007fff933e8ec6 __66-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke2304 + 365
11 AppKit 0x00007fff933e72e6 __66-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke2176 + 1587
12 AppKit 0x00007fff93426882 __62-[NSDocumentController(NSInternal) _onMainThreadInvokeWorker:]_block_invoke1881 + 175
13 CoreFoundation 0x00007fff8c56954c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
14 CoreFoundation 0x00007fff8c55b655 __CFRunLoopDoBlocks + 341
15 CoreFoundation 0x00007fff8c55b196 __CFRunLoopRun + 1814
16 CoreFoundation 0x00007fff8c55a838 CFRunLoopRunSpecific + 296
17 HIToolbox 0x00007fff9421243f RunCurrentEventLoopInMode + 235
18 HIToolbox 0x00007fff942121ba ReceiveNextEventCommon + 431
19 HIToolbox 0x00007fff94211ffb _BlockUntilNextEventMatchingListInModeWithFilter + 71
20 AppKit 0x00007fff92fbe6d1 _DPSNextEvent + 964
21 AppKit 0x00007fff92fbde80 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
22 AppKit 0x00007fff92fb1e23 -[NSApplication run] + 594
23 AppKit 0x00007fff92f9d2d4 NSApplicationMain + 1832
24 Ligre UI 0x0000000100001302 main + 34
25 libdyld.dylib 0x00007fff8cea45c9 start + 1
26 ??? 0x0000000000000003 0x0 + 3
)
Did you override dataOfType or one of the writeToURL methods?
See the discussion here: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/index.html#//apple_ref/occ/instm/NSDocument/dataOfType:error:
After upgrading to Yosemite, I'm getting a very weird crash when I run a NSSavePanel in my app. For example, I select openDocument: and it crashes. Or I open the panel to browse files and it crashes.
An uncaught exception was raised
2014-10-24 09:51:28.429 MyApp[2240:374020] *** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array
2014-10-24 09:51:28.431 MyApp[2240:374020] (
0 CoreFoundation 0x97c59343 __raiseError + 195
1 libobjc.A.dylib 0x973bea2a objc_exception_throw + 276
2 CoreFoundation 0x97b1cf8c -[__NSArrayI objectAtIndex:] + 204
3 MyApp 0x0013c830 -[NSArray(CocoaDevUsersAdditions) firstObject] + 41
4 AppKit 0x94567f16 _NSAccessibilityEntryPointValueForAttribute + 2116
5 AppKit 0x9456829e NSAccessibilityEntryPointValueForAttribute + 24
6 AppKit 0x9435ff4c ValueOfAttributeWithDefault + 80
7 AppKit 0x94090fa2 NSAccessibilityChildren + 47
8 AppKit 0x94090f48 NSAccessibilityUnignoredChildrenForOnlyChild + 99
9 AppKit 0x94090e50 NSAccessibilityUnignoredDescendant + 42
10 AppKit 0x94213a51 -[NSNibAXRelationshipConnector establishConnection] + 130
11 AppKit 0x9453e342 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1061
12 AppKit 0x93ffaad7 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 56
13 AppKit 0x945debdd -[NSNib _instantiateNibWithExternalNameTable:options:] + 735
14 AppKit 0x941a3f77 -[NSNib instantiateNibWithOwner:topLevelObjects:] + 277
15 AppKit 0x94651cee -[NSSavePanel(NSSavePanelLayout) _initContentView] + 189
16 AppKit 0x9463d317 -[NSSavePanel initWithContentRect:styleMask:backing:defer:] + 645
17 AppKit 0x9463c6db +[NSSavePanel _crunchyRawUnbonedPanel] + 216
18 AppKit 0x945e978a +[NSOpenPanel openPanel] + 33
19 AppKit 0x944b66fb -[NSDocumentController _setupOpenPanel] + 42
20 AppKit 0x944b6b62 -[NSDocumentController beginOpenPanelWithCompletionHandler:] + 96
21 AppKit 0x944b6630 -[NSDocumentController openDocument:] + 413
22 libobjc.A.dylib 0x973bc853 -[NSObject performSelector:withObject:] + 70
23 AppKit 0x94380328 __36-[NSApplication sendAction:to:from:]_block_invoke + 51
24 libsystem_trace.dylib 0x9096dc03 _os_activity_initiate + 89
25 AppKit 0x941f3a11 -[NSApplication sendAction:to:from:] + 548
26 AppKit 0x9420f9ed -[NSMenuItem _corePerformAction] + 479
27 AppKit 0x9420f6c9 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 162
28 AppKit 0x9420ed54 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
29 AppKit 0x94585872 __38-[NSMenu performActionForItemAtIndex:]_block_invoke + 52
30 libsystem_trace.dylib 0x9096dc03 _os_activity_initiate + 89
31 AppKit 0x94260736 -[NSMenu performActionForItemAtIndex:] + 141
32 AppKit 0x9426069e -[NSMenu _internalPerformActionForItemAtIndex:] + 45
33 AppKit 0x94260669 -[NSMenuItem _internalPerformActionThroughMenuIfPossible] + 106
34 AppKit 0x942604c1 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 120
35 AppKit 0x94204487 NSSLMMenuEventHandler + 679
36 HIToolbox 0x905a45d4 _Z22_InvokeEventHandlerUPPP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvPFlS0_S2_S3_E + 36
37 HIToolbox 0x903ee501 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 2291
38 HIToolbox 0x903ed4dc _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 402
39 HIToolbox 0x90400d25 SendEventToEventTarget + 88
40 HIToolbox 0x905a4452 _ZL18SendHICommandEventmPK9HICommandmmhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 447
41 HIToolbox 0x904650cc SendMenuCommandWithContextAndModifiers + 72
42 HIToolbox 0x90465074 SendMenuItemSelectedEvent + 207
43 HIToolbox 0x90464f38 _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 145
44 HIToolbox 0x905fb902 _ZL14MenuSelectCoreP8MenuData5PointdmPP13OpaqueMenuRefPt + 775
45 HIToolbox 0x9046c266 _HandleMenuSelection2 + 512
46 HIToolbox 0x9046c050 _HandleMenuSelection + 55
47 AppKit 0x94182f3b _NSHandleCarbonMenuEvent + 359
48 AppKit 0x9400e321 _DPSNextEvent + 1702
49 AppKit 0x9400d7a1 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 186
50 AppKit 0x93ffff6c -[NSApplication run] + 907
51 AppKit 0x93fe94d0 NSApplicationMain + 2082
52 MyApp 0x00003215 start + 53
This is a bug with the extension class you are using. NSArray+CocoaDevUsersAdditions firstObject method is implemented wrong. The relevant parts of the crash log you posted are these three lines:
1 libobjc.A.dylib 0x973bea2a objc_exception_throw + 276
2 CoreFoundation 0x97b1cf8c -[__NSArrayI objectAtIndex:] + 204
3 MyApp 0x0013c830 -[NSArray(CocoaDevUsersAdditions) firstObject] + 41
The index 0 beyond bounds for empty array error happens when you try to access the index 0 of an array that contains no objects.
I found some code that I think matches the NSArray+CocoaDevUsersAdditions class at this URL
-(id)firstObject
{
return [self objectAtIndex:0];
}
The above code is wrong. It should check the count of objects first. Correct code should look like this:
-(id)firstObject
{
id result = nil;
if (self.count > 0) {
result = [self objectAtIndex:0];
}
return result;
}
So the problem is the NSArray extension you are using is implemented wrong.
Best solution: Remove your NSArray+CocoaDevUsersAdditions category and use the public firstObject method on NSArray
I've got a strange problem: got a singleton which is initialized in applicationDidFinishLaunching of AppDelegate, but in some cases I receive crash reports with EXC_CRASH (SIGSEGV) and a stack trace like this:
0 com.name.myapp 0x000000010f723bae -[MySingleton .cxx_construct] (common_bootstrap.h:57)
1 libobjc.A.dylib 0x00007fff91339baa object_cxxConstructFromClass(objc_object*, objc_class*) + 151
2 libobjc.A.dylib 0x00007fff913367e4 object_cxxConstruct + 25
3 libobjc.A.dylib 0x00007fff91336795 _objc_constructOrFree + 21
4 libobjc.A.dylib 0x00007fff9134a49d +[NSObject allocWithZone:] + 16
5 com.name.myapp 0x000000010f722a11 __32+[MySingleton sharedInstance]_block_invoke (MySingleton.mm:124)
6 libdispatch.dylib 0x00007fff9377a2ad _dispatch_client_callout + 8
7 libdispatch.dylib 0x00007fff9377a21c dispatch_once_f + 79
8 com.name.myapp 0x000000010f7229f5 +[MySingleton sharedInstance] (once.h:68)
9 com.name.myapp 0x000000010f719480 -[AppDelegate applicationShouldTerminate:] (AppDelegate.m:673)
10 com.apple.AppKit 0x00007fff8d017471 -[NSApplication _docController:shouldTerminate:] + 69
11 com.apple.AppKit 0x00007fff8d017383 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 152
12 com.apple.AppKit 0x00007fff8d017122 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1292
13 com.apple.AppKit 0x00007fff8d016bbf -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 265
14 com.apple.AppKit 0x00007fff8d01688c -[NSApplication _shouldTerminate] + 663
15 com.apple.AppKit 0x00007fff8d052a34 -[NSApplication(NSAppleEventHandling) _handleAEQuit] + 357
16 com.apple.AppKit 0x00007fff8ccb7213 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 282
17 com.apple.Foundation 0x00007fff92bf1eaa -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
18 com.apple.Foundation 0x00007fff92bf1d1d _NSAppleEventManagerGenericHandler + 106
19 com.apple.AE 0x00007fff8c139e1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
20 com.apple.AE 0x00007fff8c139c32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
21 com.apple.AE 0x00007fff8c139b36 aeProcessAppleEvent + 315
22 com.apple.HIToolbox 0x00007fff8bced5f1 AEProcessAppleEvent + 56
23 com.apple.AppKit 0x00007fff8ccb30f6 _DPSNextEvent + 1026
24 com.apple.AppKit 0x00007fff8ccb28db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
25 com.apple.AppKit 0x00007fff8cca69cc -[NSApplication run] + 553
26 com.apple.AppKit 0x00007fff8cc91803 NSApplicationMain + 940
27 com.name.myapp 0x000000010f716ec4 start + 52
So I see my singleton is trying to allocate and fails, so I suppose applicationDidFinishLaunching didn't ever been called.
Why can OS X try to terminate my app before it has been launched?
I've been trying to find out what's wrong with this piece of code: I have an NSTextView which string I want to update when the user clicks in one one my table views. For now on, I'm just trying to get it to display the string "Notes".
Any idea on what I am doing wrong ? I looked into beginEditing: and endEditing: without any success.
//
// MyAppDelegate.h
#property IBOutlet NSTextView* stickyNoteContainer;
//
// MyAppDelegate.m
-(void)updateOverview{
[stickyNoteContainer setString:#"Notes"];
}
Here's the stack :
MyApp[1176:303] *** -[NSBigMutableString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]: Range or index out of bounds
2013-09-23 15:04:12.084 MyApp[1176:303] (
0 CoreFoundation 0x00007fff917eaf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff95bb7d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff917ead8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff917ead14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff955afbc5 -[NSString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:] + 160
5 Foundation 0x00007fff955afb1e -[NSString getParagraphStart:end:contentsEnd:forRange:] + 40
6 AppKit 0x00007fff8e5c1cd7 _NSFastFillAllLayoutHolesForGlyphRange + 1040
7 AppKit 0x00007fff8eb31bb4 -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtensionFactor:minimumExtensionDistance:repetitions:] + 563
8 AppKit 0x00007fff8eb2d13c -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtension:] + 45
9 AppKit 0x00007fff8e6b9650 -[NSTextView setNeedsDisplayInRect:avoidAdditionalLayout:] + 2078
10 AppKit 0x00007fff8e6bf1c1 -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] + 5690
11 AppKit 0x00007fff8e5b0110 -[NSLayoutManager(NSPrivate) _recalculateUsageForTextContainerAtIndex:] + 2678
12 AppKit 0x00007fff8e96b948 _enableTextViewResizing + 209
13 AppKit 0x00007fff8e5a8454 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 582
14 AppKit 0x00007fff8e5a81f6 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 155
15 AppKit 0x00007fff8e681133 -[NSTextStorage processEditing] + 205
16 AppKit 0x00007fff8e681cab -[NSTextStorage endEditing] + 81
17 MyApp 0x0000000100007938 -[MyAppDelegate updateOverview] + 1624
18 MyApp 0x0000000100008751 -[MyAppDelegate tableViewSelectionDidChange:] + 177
19 Foundation 0x00007fff95550d0e __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47
20 CoreFoundation 0x00007fff917937ba _CFXNotificationPost + 2634
21 Foundation 0x00007fff9553cfc3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65
22 AppKit 0x00007fff8e674049 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 203
23 AppKit 0x00007fff8e64ab0a -[NSTableView _enableSelectionPostingAndPost] + 425
24 AppKit 0x00007fff8e670e58 -[NSTableView mouseDown:] + 5030
25 AppKit 0x00007fff8e5d6c98 -[NSWindow sendEvent:] + 6306
26 AppKit 0x00007fff8e5703a5 -[NSApplication sendEvent:] + 5593
27 AppKit 0x00007fff8e506a0e -[NSApplication run] + 555
28 AppKit 0x00007fff8e782eac NSApplicationMain + 867
29 MyApp 0x0000000100002002 main + 34
30 MyApp 0x0000000100001fd4 start + 52
)
EDIT : I realized the piece of code actually runs twice without any exception at the end of the program initialization, during my - (void)applicationDidFinishLaunching: routine. After that, any triggering will be faulty. What does this suggest ?
EDIT 2 : Put aside the fact using insertText: appends instead of replacing, I get a very similar exception when trying :
MyApp[1919:303] *** -[NSBigMutableString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]: Range or index out of bounds
2013-09-23 15:34:03.956 MyApp[1919:303] (
0 CoreFoundation 0x00007fff917eaf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff95bb7d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff917ead8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff917ead14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff955afbc5 -[NSString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:] + 160
5 Foundation 0x00007fff955afb1e -[NSString getParagraphStart:end:contentsEnd:forRange:] + 40
6 AppKit 0x00007fff8e5c1cd7 _NSFastFillAllLayoutHolesForGlyphRange + 1040
7 AppKit 0x00007fff8eb31bb4 -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtensionFactor:minimumExtensionDistance:repetitions:] + 563
8 AppKit 0x00007fff8eb2d13c -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtension:] + 45
9 AppKit 0x00007fff8e6b9650 -[NSTextView setNeedsDisplayInRect:avoidAdditionalLayout:] + 2078
10 AppKit 0x00007fff8e6bf1c1 -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] + 5690
11 AppKit 0x00007fff8e5b0110 -[NSLayoutManager(NSPrivate) _recalculateUsageForTextContainerAtIndex:] + 2678
12 AppKit 0x00007fff8e96b948 _enableTextViewResizing + 209
13 AppKit 0x00007fff8e5a8454 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 582
14 AppKit 0x00007fff8e5a81f6 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 155
15 AppKit 0x00007fff8e681133 -[NSTextStorage processEditing] + 205
16 AppKit 0x00007fff8e681cab -[NSTextStorage endEditing] + 81
17 AppKit 0x00007fff8eb0620f -[NSTextView insertText:replacementRange:] + 2013
18 AppKit 0x00007fff8eb05a25 -[NSTextView insertText:] + 320
19 MyApp 0x00000001000078c1 -[MyAppDelegate updateOverview] + 1569
20 MyApp 0x0000000100008751 -[MyAppDelegate tableViewSelectionDidChange:] + 177
21 Foundation 0x00007fff95550d0e __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47
22 CoreFoundation 0x00007fff917937ba _CFXNotificationPost + 2634
23 Foundation 0x00007fff9553cfc3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65
24 AppKit 0x00007fff8e674049 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 203
25 AppKit 0x00007fff8e64ab0a -[NSTableView _enableSelectionPostingAndPost] + 425
26 AppKit 0x00007fff8e670e58 -[NSTableView mouseDown:] + 5030
27 AppKit 0x00007fff8e5d6c98 -[NSWindow sendEvent:] + 6306
28 AppKit 0x00007fff8e5703a5 -[NSApplication sendEvent:] + 5593
29 AppKit 0x00007fff8e506a0e -[NSApplication run] + 555
30 AppKit 0x00007fff8e782eac NSApplicationMain + 867
31 MyApp 0x0000000100001fc2 main + 34
32 MyApp 0x0000000100001f94 start + 52
)
It turned out I was modifying the stringValue of a NSTextView while it was calling textDidEndEditing:, which resulted in a mismatched string count and a Range or index out of bounds exception thrown when this wrong count was being used inside NSTextView inner methods.
I just bypassed the problem by using an ivar #property BOOL canModifyTextViewString which would be set accordingly inside methods where modifying the string is unsafe/not possible.
NSTextView doesn't have setString as a class method
-(void)updateOverview{
[stickyNoteContainer insertText:#"Notes"];
}
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTextView/insertText:
I have a WebView in a NSWindow and when I close the window and open it again the app crashes ;(
The window is called by a menu item button.
Here is the output:
2011-10-22 15:55:32.440 Textis[17176:903] -[__NSCFType mainFrame]: unrecognized selector sent to instance 0x100514e90
2011-10-22 15:55:32.544 Textis[17176:903] HIToolbox: ignoring exception '-[__NSCFType mainFrame]: unrecognized selector sent to instance 0x100514e90' that raised inside Carbon event dispatch
(
0 CoreFoundation 0x00007fff838b17b4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff8127af03 objc_exception_throw + 45
2 CoreFoundation 0x00007fff8390b110 +[NSObject(NSObject) doesNotRecognizeSelector:] + 0
3 CoreFoundation 0x00007fff8388391f ___forwarding___ + 751
4 CoreFoundation 0x00007fff8387fa68 _CF_forwarding_prep_0 + 232
5 Textis 0x0000000100003722 -[Share tweet:] + 210
6 AppKit 0x00007fff84b3eeda -[NSApplication sendAction:to:from:] + 95
7 AppKit 0x00007fff84b6346a -[NSMenuItem _corePerformAction] + 365
8 AppKit 0x00007fff84b631d4 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 121
9 AppKit 0x00007fff84de8cf4 -[NSMenu _internalPerformActionForItemAtIndex:] + 35
10 AppKit 0x00007fff84c9a9e9 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 136
11 AppKit 0x00007fff84b4599c NSSLMMenuEventHandler + 321
12 HIToolbox 0x00007fff8665d7f7 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1002
13 HIToolbox 0x00007fff8665cd46 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 395
14 HIToolbox 0x00007fff8667aa81 SendEventToEventTarget + 45
15 HIToolbox 0x00007fff866a9c35 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 387
16 HIToolbox 0x00007fff866d6a0a SendMenuCommandWithContextAndModifiers + 56
17 HIToolbox 0x00007fff866d69c2 SendMenuItemSelectedEvent + 101
18 HIToolbox 0x00007fff866d68d2 _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 150
19 HIToolbox 0x00007fff867dfa69 _ZL19PopUpMenuSelectCoreP8MenuData5PointdS1_tjPK4RecttjS4_S4_PK10__CFStringPP13OpaqueMenuRefPt + 1618
20 HIToolbox 0x00007fff867dfdc2 _HandlePopUpMenuSelection7 + 665
21 AppKit 0x00007fff84c9799b _NSSLMPopUpCarbonMenu3 + 3720
22 AppKit 0x00007fff84ec76f9 -[NSStatusBarButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 162
23 AppKit 0x00007fff84bc92f5 -[NSControl mouseDown:] + 624
24 AppKit 0x00007fff84ae33a7 -[NSWindow sendEvent:] + 5409
25 AppKit 0x00007fff84ec8498 -[NSStatusBarWindow sendEvent:] + 68
26 AppKit 0x00007fff84a18afa -[NSApplication sendEvent:] + 4719
27 AppKit 0x00007fff849af6de -[NSApplication run] + 474
28 AppKit 0x00007fff849a83b0 NSApplicationMain + 364
29 Textis 0x00000001000010c2 main + 34
30 Textis 0x0000000100001094 start + 52
31 ??? 0x0000000000000001 0x0 + 1
)
mainFrame is a method on WebView
so
2011-10-22 15:55:32.544 Textis[17176:903] HIToolbox: ignoring exception '-[__NSCFType mainFrame]: unrecognized selector sent to instance 0x100514e90' that raised inside Carbon event dispatch
points to your WebView being released either by you explicitly or implicitly by the OS when the window is shut. You are hitting a dead pointer.
Not sure how you are setting up your window but you are probably assuming that the original WebView is still a valid object at a reopen.
Have a look in that direction.