My macOS app is idle but the NSOutlineView is constantly being updated and taking 40% CPU. The only code of mine being called is the objectValueForTableColumn NSOutlineViewDataSource method, about 20 times a second.
Using Instruments it looks like the main runloop is constantly finding a Core Animation task to commit. (See 46-44 below).
59 libdyld.dylib 3435.0 start
58 FrogRadio 3435.0 main /Users/robertdodson/Pro/dev/FrogRadio/FrogRadio/FrogRadio/Main/main.m:13
57 AppKit 3435.0 NSApplicationMain
56 AppKit 3435.0 -[NSApplication run]
55 AppKit 3426.0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
54 AppKit 3409.0 _DPSNextEvent
53 HIToolbox 3408.0 _BlockUntilNextEventMatchingListInModeWithFilter
52 HIToolbox 3408.0 ReceiveNextEventCommon
51 HIToolbox 3401.0 RunCurrentEventLoopInMode
50 CoreFoundation 3393.0 CFRunLoopRunSpecific
49 CoreFoundation 3386.0 __CFRunLoopRun
48 CoreFoundation 3192.0 __CFRunLoopDoObservers
47 CoreFoundation 3185.0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
46 AppKit 3158.0 __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke
45 QuartzCore 3117.0 CA::Transaction::commit()
44 QuartzCore 2957.0 CA::Transaction::run_commit_handlers(CATransactionPhase)
43 AppKit 2957.0 __37+[NSDisplayCycle currentDisplayCycle]_block_invoke
42 AppKit 2948.0 ___NSWindowGetDisplayCycleObserver_block_invoke.5902
41 AppKit 2936.0 -[NSWindow displayIfNeeded]
40 AppKit 2935.0 -[NSView displayIfNeeded]
39 AppKit 2874.0 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
38 AppKit 2872.0 -[NSView _oldDisplayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
37 AppKit 2816.0 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
...
I have no Core Animation code in my app. I have refactored recently, and this is a new problem, but I can not see what I have done to cause it.
Any ideas here?
Thanks,
Rob
Update: adding full stack trace at objectValueForTableColumn call:
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x000000010001a3db FrogRadio`-[FRGTree outlineView:objectValueForTableColumn:byItem:](self=0x0000600000002b10, _cmd="outlineView:objectValueForTableColumn:byItem:", outlineView=0x0000000101c04130, tableColumn=0x000060c000082300, item=0x00006000000e7600) at FRGTree.m:101
frame #1: 0x00007fff2cd52756 AppKit`-[NSTableView preparedCellAtColumn:row:] + 471
frame #2: 0x00007fff2cdd60af AppKit`-[NSOutlineView preparedCellAtColumn:row:] + 51
frame #3: 0x00007fff2cd523e7 AppKit`-[NSTableView _drawContentsAtRow:column:withCellFrame:] + 50
frame #4: 0x00007fff2cdd601f AppKit`-[NSOutlineView _drawContentsAtRow:column:withCellFrame:] + 92
frame #5: 0x00007fff2cd520f2 AppKit`-[NSTableView drawRow:clipRect:] + 2186
frame #6: 0x00007fff2cd51568 AppKit`-[NSTableView drawRowIndexes:clipRect:] + 527
frame #7: 0x00007fff2cdd0ec2 AppKit`-[NSOutlineView drawRowIndexes:clipRect:] + 112
frame #8: 0x00007fff2cc6fced AppKit`-[NSTableView drawRect:] + 1522
frame #9: 0x00007fff2d3bac21 AppKit`_NSViewDrawRect + 83
frame #10: 0x00007fff2cc53b38 AppKit`-[NSView _drawRect:clip:] + 1819
frame #11: 0x00007fff2cc9bf62 AppKit`-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1735
frame #12: 0x00007fff2cc9c42f AppKit`-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2964
frame #13: 0x00007fff2cc51a52 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 938
frame #14: 0x00007fff2cc522c1 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 3097
frame #15: 0x00007fff2cc522c1 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 3097
frame #16: 0x00007fff2cc522c1 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 3097
frame #17: 0x00007fff2cc511db AppKit`-[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 327
frame #18: 0x00007fff2d3bc1d8 AppKit`-[NSView _oldDisplayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2051
frame #19: 0x00007fff2cc50261 AppKit`-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 253
frame #20: 0x00007fff2cc4c4b8 AppKit`-[NSView displayIfNeeded] + 1581
frame #21: 0x00007fff2cc4be56 AppKit`-[NSWindow displayIfNeeded] + 321
frame #22: 0x00007fff2d3ec2d9 AppKit`___NSWindowGetDisplayCycleObserver_block_invoke.5902 + 308
frame #23: 0x00007fff2cc4b962 AppKit`__37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 695
frame #24: 0x00007fff3a65878f QuartzCore`CA::Transaction::run_commit_handlers(CATransactionPhase) + 49
frame #25: 0x00007fff3a657301 QuartzCore`CA::Transaction::commit() + 171
frame #26: 0x00007fff2d403658 AppKit`__65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke + 283
frame #27: 0x00007fff2f548127 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
frame #28: 0x00007fff2f54804f CoreFoundation`__CFRunLoopDoObservers + 527
frame #29: 0x00007fff2f52a6a8 CoreFoundation`__CFRunLoopRun + 1240
frame #30: 0x00007fff2f529f43 CoreFoundation`CFRunLoopRunSpecific + 483
frame #31: 0x00007fff2e841e26 HIToolbox`RunCurrentEventLoopInMode + 286
frame #32: 0x00007fff2e841b96 HIToolbox`ReceiveNextEventCommon + 613
frame #33: 0x00007fff2e841914 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
frame #34: 0x00007fff2cb0cf5f AppKit`_DPSNextEvent + 2085
frame #35: 0x00007fff2d2a2b4c AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
frame #36: 0x00007fff2cb01d6d AppKit`-[NSApplication run] + 764
frame #37: 0x00007fff2cad0f1a AppKit`NSApplicationMain + 804
frame #38: 0x00000001000456e2 FrogRadio`main(argc=3, argv=0x00007ffeefbff340) at main.m:13
frame #39: 0x00007fff56e41115 libdyld.dylib`start + 1
Update 2: My NSOutlineViewDataSource code:
- (NSInteger) outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
return (item == nil) ? 1 : ((FRGTreeNode*)item).children.count;
}
- (BOOL) outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
return [((FRGTreeNode*)item) isExpandable];
}
- (id) outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
return (!item) ? _rootNode : ((FRGTreeNode*)item).children[index];
}
- (id) outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSLog(#"tree: %#",((FRGTreeNode*)item).nodename);
return ((FRGTreeNode*)item).nodename;
}
Some notes: The NSLog method is getting call many times a second. Also, the outlineView works fine even though this is happening.
I was calling setNeedsDisplay in the outlineView dataCellForTableColumn for each cell in order have updated highlighting be correct, which is a bad idea. I will make this code smarter.
Related
In our app we call a method that adds two navigation controllers to a UISplitViewController via the viewControllers property. We do this in multiple places in our app, but this one place is causing a SIGABRT and I cannot figure out why. The UISplitViewController.viewControllers already has two view controllers in the NSArray at this point. The error happens only when the device is in portrait and only on iOS 8.
The error that comes with the SIGABRT is:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 11 beyond bounds [0 .. 10]'
The line of code that causes the error is
self.splitViewController.viewControllers = #[mainNav.navigationController, genericNavVC];
It has to be something with the property because it doesn't seem to matter what I try to assign to it (nil, 2 blank UINavigationControllers, etc.). I've also tried using the setViewControllers method but it still errs.
Does anyone know what might be causing this and is there something we could use as a workaround?
-- Extra Info --
NSLog of the exception callStackSymbols:
(
0 CoreFoundation 0x24ce6d7f <redacted> + 150
1 libobjc.A.dylib 0x3285dc77 objc_exception_throw + 38
2 CoreFoundation 0x24bfafb7 <redacted> + 230
3 myApp 0x00212ef7 -[DocsToSign objectAtIndex:] + 62
4 myApp 0x001436d3 -[DocsToSignListViewController tableView:cellForRowAtIndexPath:] + 966
5 UIKit 0x2845126d <redacted> + 476
6 UIKit 0x2845132f <redacted> + 54
7 UIKit 0x28446a51 <redacted> + 2276
8 UIKit 0x2825ec1b <redacted> + 186
9 UIKit 0x28188c1f <redacted> + 514
10 QuartzCore 0x27bb3f65 <redacted> + 136
11 QuartzCore 0x27baf951 <redacted> + 360
12 UIKit 0x2819b367 <redacted> + 138
13 UIKit 0x282358ed <redacted> + 872
14 UIKit 0x2836643d <redacted> + 284
15 UIKit 0x28232803 <redacted> + 78
16 UIKit 0x28480949 <redacted> + 536
17 UIKit 0x286474cd <redacted> + 168
18 UIKit 0x28647283 <redacted> + 138
19 UIKit 0x28474487 <redacted> + 350
20 UIKit 0x28636d13 <redacted> + 170
21 myApp 0x000eb5db -[AppDelegate_iPad ClearDetailView] + 1446
22 myApp 0x001478e9 -[DocsToSignListViewController SignDocsComplete:withResponseData:] + 1564
23 myApp 0x000fbae3 -[WCFHandler requestCompleted] + 846
24 myApp 0x000fc353 -[WCFHandler connectionDidFinishLoading:] + 86
25 CFNetwork 0x24840045 <redacted> + 56
26 CFNetwork 0x2483ffff <redacted> + 182
27 CFNetwork 0x248400f1 <redacted> + 36
28 CFNetwork 0x2475527b <redacted> + 78
29 CFNetwork 0x247f18c5 <redacted> + 60
30 CFNetwork 0x24746189 <redacted> + 60
31 CoreFoundation 0x24bf83f1 CFArrayApplyFunction + 36
32 CFNetwork 0x24746043 <redacted> + 182
33 CFNetwork 0x24745f09 <redacted> + 216
34 CFNetwork 0x24745da5 <redacted> + 48
35 CoreFoundation 0x24cad5e7 <redacted> + 14
36 CoreFoundation 0x24cac9fb <redacted> + 222
37 CoreFoundation 0x24cab079 <redacted> + 768
38 CoreFoundation 0x24bf8981 CFRunLoopRunSpecific + 476
39 CoreFoundation 0x24bf8793 CFRunLoopRunInMode + 106
40 GraphicsServices 0x2bfa8051 GSEventRunModal + 136
41 UIKit 0x281ea981 UIApplicationMain + 1440
42 myApp 0x000e8a09 main + 48
43 libdyld.dylib 0x32df9aaf <redacted> + 2
)
And this is from calling thread backtrace at exception time:
* thread #1: tid = 0x2259, 0x000eb71c myApp`-[AppDelegate_iPad ClearDetailView](self=0x15571b80, _cmd=0x002b2ecd) + 1768 at AppDelegate_iPad.m:332, queue = 'com.apple.main-thread', stop reason = step over
* frame #0: 0x000eb71c myApp`-[AppDelegate_iPad ClearDetailView](self=0x15571b80, _cmd=0x002b2ecd) + 1768 at AppDelegate_iPad.m:332
frame #1: 0x001478e8 myApp`-[DocsToSignListViewController SignDocsComplete:withResponseData:](self=0x155b7820, _cmd=0x002b968f, handler=0x15511f10, responseData=0x1558ef90) + 1564 at DocsToSignListViewController.m:690
frame #2: 0x000fbae2 myApp`-[WCFHandler requestCompleted](self=0x1550b040, _cmd=0x2bf7076d) + 846 at WCFHandler.m:161
frame #3: 0x000fc352 myApp`-[WCFHandler connectionDidFinishLoading:](self=0x1550b040, _cmd=0x2898e975, connection=0x15567af0) + 86 at WCFHandler.m:243
frame #4: 0x24840044 CFNetwork`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 56
frame #5: 0x2483fffe CFNetwork`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 182
frame #6: 0x248400f0 CFNetwork`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 36
frame #7: 0x2475527a CFNetwork`___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 78
frame #8: 0x247f18c4 CFNetwork`___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 60
frame #9: 0x24746188 CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 60
frame #10: 0x24bf83f0 CoreFoundation`CFArrayApplyFunction + 36
frame #11: 0x24746042 CFNetwork`RunloopBlockContext::perform() + 182
frame #12: 0x24745f08 CFNetwork`MultiplexerSource::perform() + 216
frame #13: 0x24745da4 CFNetwork`MultiplexerSource::_perform(void*) + 48
frame #14: 0x24cad5e6 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
frame #15: 0x24cac9fa CoreFoundation`__CFRunLoopDoSources0 + 222
frame #16: 0x24cab078 CoreFoundation`__CFRunLoopRun + 768
frame #17: 0x24bf8980 CoreFoundation`CFRunLoopRunSpecific + 476
frame #18: 0x24bf8792 CoreFoundation`CFRunLoopRunInMode + 106
frame #19: 0x2bfa8050 GraphicsServices`GSEventRunModal + 136
frame #20: 0x281ea980 UIKit`UIApplicationMain + 1440
frame #21: 0x000e8a08 myApp`main(argc=1, argv=0x0054cafc) + 48 at main.m:14
I get the message, 'Thread 1: breakpoint 1.1' after I run my code in xcode, which I believe is referring to the exception breakpoint, 'All Exceptions' I've added. The 'Thread 1: breakpoint 1.1' shows up highlighting in green the thread in my main file
return UIApplicationMain(argc, argv, nil, NSStringFromClass([CardGameAppDelegate class]));
My debugger console only says, '(lldb)'. After running 'bt' (backtrace) in the console, this is what is returned:
* thread #1: tid = 0x1b2bb4, 0x015748b9 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x015748b9 libobjc.A.dylib`objc_exception_throw
frame #1: 0x01884fe1 CoreFoundation`-[NSException raise] + 17
frame #2: 0x01234d9e Foundation`-[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
frame #3: 0x011a11d7 Foundation`_NSSetUsingKeyValueSetter + 88
frame #4: 0x011a0731 Foundation`-[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
frame #5: 0x01202b0a Foundation`-[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
frame #6: 0x004eb1f4 UIKit`-[UIRuntimeOutletConnection connect] + 106
frame #7: 0x015867de libobjc.A.dylib`-[NSObject performSelector:] + 62
frame #8: 0x017f076a CoreFoundation`-[NSArray makeObjectsPerformSelector:] + 314
frame #9: 0x004e9d4d UIKit`-[UINib instantiateWithOwner:options:] + 1417
frame #10: 0x003526f5 UIKit`-[UIViewController _loadViewFromNibNamed:bundle:] + 280
frame #11: 0x00352e9d UIKit`-[UIViewController loadView] + 302
frame #12: 0x003530d3 UIKit`-[UIViewController loadViewIfRequired] + 78
frame #13: 0x003535d9 UIKit`-[UIViewController view] + 35
frame #14: 0x00273267 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 66
frame #15: 0x002735ef UIKit`-[UIWindow _setHidden:forced:] + 312
frame #16: 0x0027386b UIKit`-[UIWindow _orderFrontWithoutMakingKey] + 49
frame #17: 0x0027e3c8 UIKit`-[UIWindow makeKeyAndVisible] + 65
frame #18: 0x0022ebc0 UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
frame #19: 0x00233667 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
frame #20: 0x00247f92 UIKit`-[UIApplication handleEvent:withNewEvent:] + 3517
frame #21: 0x00248555 UIKit`-[UIApplication sendEvent:] + 85
frame #22: 0x00235250 UIKit`_UIApplicationHandleEvent + 683
frame #23: 0x037eaf02 GraphicsServices`_PurpleEventCallback + 776
frame #24: 0x037eaa0d GraphicsServices`PurpleEventCallback + 46
frame #25: 0x01770ca5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #26: 0x017709db CoreFoundation`__CFRunLoopDoSource1 + 523
frame #27: 0x0179b68c CoreFoundation`__CFRunLoopRun + 2156
frame #28: 0x0179a9d3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #29: 0x0179a7eb CoreFoundation`CFRunLoopRunInMode + 123
frame #30: 0x00232d9c UIKit`-[UIApplication _run] + 840
frame #31: 0x00234f9b UIKit`UIApplicationMain + 1225
* frame #32: 0x0000509d Matchismo`main(argc=1, argv=0xbfffedd8) + 141 at main.m:16
I'm not entirely sure how to decipher this. From the guides I've been followed, they say that after including the 'All Exceptions' breakpoint, the thrown exception should be outlined in my source code. If someone could help guide about how to figure out the source of my crash, I would greatly appreciate it!
According to the stack trace, the problem occurs when your view controller attempts to load a nib file.
frame #10: 0x003526f5 UIKit`-[UIViewController _loadViewFromNibNamed:bundle:] + 280
The problem appears to be that the unarchiver is unable to set an outlet configured in the nib file.
frame #6: 0x004eb1f4 UIKit`-[UIRuntimeOutletConnection connect] + 106
To get precise details about the exception, press the debugger's continue button (or type continue, or just c for short, in the console). You may need to do this twice to get all the information.
The exception message should provide you the exact name of the outlet. Perhaps you renamed or deleted a property after you had already set the outlet in Interface Builder. If you inspect the view controller in IB, you should see a yellow warning flag next to any stale outlets. Just click the x to delete.
The reason the debugger appears to stop in main rather than somewhere else is because the exception wasn't thrown in your code, so there's no matching source line for it do display.
all. when I use NSTableView, it will give me the following errors as long as it reaches in this function.
-(id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
USBInfor* usbInfor = [_tableContent objectAtIndex:row];
NSString* identifier = [tableColumn identifier];
return [usbInfor valueForKey:identifier];
}
I created a usbInfor class to save name, size, path, and type of USB. And I add those variables into _tableContent NSMutableArray.
USBInfor *usbinfor = [[USBInfor alloc]init];
usbinfor.name = [mountPath substringFromIndex:9];
usbinfor.path = mountPath;
usbinfor.size = formattingSize;
usbinfor.type = type;
[_tableContent addObject:usbinfor];
I created 3 columns in xib file and each of the identifier I named the same as the variables' name which are name, path, and size.
Here are the errors:
2013-05-08 22:56:34.157 TESTING[7760:303] -[__NSCFString setFrame:]: unrecognized selector sent to instance 0x10022a3d0
2013-05-08 22:56:34.158 TESTING[7760:303] An uncaught exception was raised
2013-05-08 22:56:34.159 TESTING[7760:303] -[__NSCFString setFrame:]: unrecognized selector sent to instance 0x10022a3d0
2013-05-08 22:56:34.162 TESTING[7760:303] (
0 CoreFoundation 0x00007fff81e8ab06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff81a003f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff81f2140a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff81e7902e ___forwarding___ + 414
4 CoreFoundation 0x00007fff81e78e18 _CF_forwarding_prep_0 + 232
5 AppKit 0x00007fff8c456a73 -[NSTableRowData _addViewToRowView:atColumn:row:] + 533
6 AppKit 0x00007fff8c45666f -[NSTableRowData _addViewsToRowView:atRow:] + 151
7 AppKit 0x00007fff8c454c05 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 415
8 AppKit 0x00007fff8c45498a -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 272
9 AppKit 0x00007fff8c453c59 -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 740
10 AppKit 0x00007fff8c4537f1 -[NSTableRowData updateVisibleRowViews] + 119
11 AppKit 0x00007fff8c42b87b -[NSTableView viewWillDraw] + 165
12 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
13 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
14 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
15 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
16 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
17 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
18 AppKit 0x00007fff8c393aa5 -[NSScrollView viewWillDraw] + 45
19 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
20 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
21 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
22 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
23 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
24 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
25 AppKit 0x00007fff8c308584 -[NSView _sendViewWillDrawInRect:clipRootView:] + 1525
26 AppKit 0x00007fff8c2d49b1 -[NSView displayIfNeeded] + 1044
27 AppKit 0x00007fff8c391a48 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1377
28 AppKit 0x00007fff8c391068 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 940
29 AppKit 0x00007fff8c390c4f -[NSWindow orderWindow:relativeTo:] + 159
30 AppKit 0x00007fff8c292266 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1424
31 AppKit 0x00007fff8c27114d loadNib + 317
32 AppKit 0x00007fff8c270679 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 219
33 AppKit 0x00007fff8c3c35bc +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 140
34 AppKit 0x00007fff8c270398 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 626
35 AppKit 0x00007fff8c26ca2f NSApplicationMain + 398
36 TESTING 0x00000001000012b2 main + 34
37 TESTING 0x0000000100001264 start + 52
)
2013-05-08 22:56:34.164 TESTING[7760:303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x10022a3d0'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff81e8ab06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff81a003f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff81f2140a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff81e7902e ___forwarding___ + 414
4 CoreFoundation 0x00007fff81e78e18 _CF_forwarding_prep_0 + 232
5 AppKit 0x00007fff8c456a73 -[NSTableRowData _addViewToRowView:atColumn:row:] + 533
6 AppKit 0x00007fff8c45666f -[NSTableRowData _addViewsToRowView:atRow:] + 151
7 AppKit 0x00007fff8c454c05 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 415
8 AppKit 0x00007fff8c45498a -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 272
9 AppKit 0x00007fff8c453c59 -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 740
10 AppKit 0x00007fff8c4537f1 -[NSTableRowData updateVisibleRowViews] + 119
11 AppKit 0x00007fff8c42b87b -[NSTableView viewWillDraw] + 165
12 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
13 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
14 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
15 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
16 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
17 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
18 AppKit 0x00007fff8c393aa5 -[NSScrollView viewWillDraw] + 45
19 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
20 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
21 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
22 AppKit 0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307
23 CoreFoundation 0x00007fff81e834a6 __NSArrayEnumerate + 582
24 AppKit 0x00007fff8c308f2d -[NSView viewWillDraw] + 244
25 AppKit 0x00007fff8c308584 -[NSView _sendViewWillDrawInRect:clipRootView:] + 1525
26 AppKit 0x00007fff8c2d49b1 -[NSView displayIfNeeded] + 1044
27 AppKit 0x00007fff8c391a48 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1377
28 AppKit 0x00007fff8c391068 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 940
29 AppKit 0x00007fff8c390c4f -[NSWindow orderWindow:relativeTo:] + 159
30 AppKit 0x00007fff8c292266 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1424
31 AppKit 0x00007fff8c27114d loadNib + 317
32 AppKit 0x00007fff8c270679 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 219
33 AppKit 0x00007fff8c3c35bc +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 140
34 AppKit 0x00007fff8c270398 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 626
35 AppKit 0x00007fff8c26ca2f NSApplicationMain + 398
36 TESTING 0x00000001000012b2 main + 34
37 TESTING 0x0000000100001264 start + 52
)
libc++abi.dylib: terminate called throwing an exception
It has to run under OS X 10.5 and the base SDK OS X 10.7
Thanks !!
The method, tableView:viewForTableColumn:row: needs to return an NSView or a subclass of NSView. It looks like [usbInfor valueForKey:identifier], where identifier is "name", returns a string ([mountPath substringFromIndex:9]). I don't know what you're trying to do there, but that's clearly wrong.
[tableColumn identifier] is used to identify a column name. So it should be something like
NSString *filename = [[itemArray1 objectAtIndex:rowIndex] objectForKey:key1a];
NSString *path = [[itemArray1 objectAtIndex:rowIndex] objectForKey:key1b];
NSString *identifier = [tableColumn identifier];
if ([identifier] isEqualToString:#"whatever a column name is"]) {
return filename;
}
else if ([identifier] isEqualToString:#"whatever a column name is"]) {
return path;
}
...
I've spent a few days trying to track down this issue with no luck so far.
I am trying to measure test coverage in my project, a Mac OS application developed in Objective-C with Xcode, and this means enabling "Instrument Program Flow" and "Generate Test Coverage Files" in the build settings. I believe these correspond to the -fprofile-arcs and -ftest-coverage flags in clang.
When these are enabled (although it seems only -fprofile-arcs affects this issue) the program will crash with an EXC_BAD_ACCESS exception in objc_msgSend in certain places.
When running the application itself, this happens when the first network request is returned. The backtrace contains none of my code, and appears to occur entirely within the Foundation/Cocoa frameworks. While this was annoying, I put up with toggling the build setting on/off depending on whether I was running tests or using the application.
I have now encountered what appears to be the same issue while testing. I have just written a test that includes network access and the tests fail with apparently the same exception in the same location, when instrumenting program flow.
I need to figure out what's causing this. The application I'm developing is for a university project, and one of the goals is to report test coverage and evaluate the testing process. This is quite difficult to do when large parts of the application can't be tested because the tests crash.
* thread #1: tid = 0x2203, 0x00007fff8ffb6250 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x00007fff8ffb6250 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x00007fff88ffe708 Foundation`___NSURLConnectionWillCacheResponse_block_invoke_0 + 110
frame #2: 0x00007fff88e86528 Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 28
frame #3: 0x00007fff88e8646c Foundation`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 227
frame #4: 0x00007fff88e86368 Foundation`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 63
frame #5: 0x00007fff88ffda3c Foundation`_NSURLConnectionWillCacheResponse + 126
frame #6: 0x00007fff879f8272 CFNetwork`___delegate_willCacheResponse_block_invoke_0 + 48
frame #7: 0x00007fff87a75a7a CFNetwork`___withDelegateAsync_block_invoke_0 + 90
frame #8: 0x00007fff87b062ea CFNetwork`__block_global_1 + 28
frame #9: 0x00007fff90110154 CoreFoundation`CFArrayApplyFunction + 68
frame #10: 0x00007fff87a667e4 CFNetwork`RunloopBlockContext::perform() + 124
frame #11: 0x00007fff87a666bb CFNetwork`MultiplexerSource::perform() + 221
frame #12: 0x00007fff900f1b31 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #13: 0x00007fff900f1455 CoreFoundation`__CFRunLoopDoSources0 + 245
frame #14: 0x00007fff901147f5 CoreFoundation`__CFRunLoopRun + 789
frame #15: 0x00007fff901140e2 CoreFoundation`CFRunLoopRunSpecific + 290
frame #16: 0x00007fff8a660eb4 HIToolbox`RunCurrentEventLoopInMode + 209
frame #17: 0x00007fff8a660c52 HIToolbox`ReceiveNextEventCommon + 356
frame #18: 0x00007fff8a660ae3 HIToolbox`BlockUntilNextEventMatchingListInMode + 62
frame #19: 0x00007fff92804563 AppKit`_DPSNextEvent + 685
frame #20: 0x00007fff92803e22 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
frame #21: 0x00007fff927fb1d3 AppKit`-[NSApplication run] + 517
frame #22: 0x00007fff9279fc06 AppKit`NSApplicationMain + 869
frame #23: 0x0000000100001842 River`main(argc=5, argv=0x00007fff5fbff7b0) + 34 at main.m:13
frame #24: 0x00007fff93aed7e1 libdyld.dylib`start + 1
And here's the backtrace when running the tests:
* thread #1: tid = 0x2503, 0x00007fff8ffb6250 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x00007fff8ffb6250 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x00007fff88ffe708 Foundation`___NSURLConnectionWillCacheResponse_block_invoke_0 + 110
frame #2: 0x00007fff88e86528 Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 28
frame #3: 0x00007fff88e8646c Foundation`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 227
frame #4: 0x00007fff88e86368 Foundation`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 63
frame #5: 0x00007fff88ffda3c Foundation`_NSURLConnectionWillCacheResponse + 126
frame #6: 0x00007fff879f8272 CFNetwork`___delegate_willCacheResponse_block_invoke_0 + 48
frame #7: 0x00007fff87a75a7a CFNetwork`___withDelegateAsync_block_invoke_0 + 90
frame #8: 0x00007fff87b062ea CFNetwork`__block_global_1 + 28
frame #9: 0x00007fff90110154 CoreFoundation`CFArrayApplyFunction + 68
frame #10: 0x00007fff87a667e4 CFNetwork`RunloopBlockContext::perform() + 124
frame #11: 0x00007fff87a666bb CFNetwork`MultiplexerSource::perform() + 221
frame #12: 0x00007fff900f1b31 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #13: 0x00007fff900f1455 CoreFoundation`__CFRunLoopDoSources0 + 245
frame #14: 0x00007fff901147f5 CoreFoundation`__CFRunLoopRun + 789
frame #15: 0x00007fff901140e2 CoreFoundation`CFRunLoopRunSpecific + 290
frame #16: 0x00007fff88f03f5e Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 268
frame #17: 0x00007fff88f03e0b Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 78
frame #18: 0x00000001006beba2 RiverTests`runExampleBlock(block=0x00000001020b68b0, name=0x00000001020b6950) + 562 at SPTExampleGroup.m:31
frame #19: 0x00000001006bfd08 RiverTests`__48-[SPTExampleGroup compileExamplesWithNameStack:]_block_invoke(.block_descriptor=0x00000001020b6a50) + 200 at SPTExampleGroup.m:241
frame #20: 0x00000001006c0877 RiverTests`-[SPTSenTestCase SPT_runExampleAtIndex:](self=0x00000001020e04a0, _cmd=0x0000000100519090, index=0) + 423 at SPTSenTestCase.m:61
frame #21: 0x00000001006c0bfd RiverTests`__33+[SPTSenTestCase testInvocations]_block_invoke(.block_descriptor=0x00000001020e03d0) + 61 at SPTSenTestCase.m:82
frame #22: 0x00000001006c142d RiverTests`-[SPTSenTestInvocation invoke](self=0x00000001020e0170, _cmd=0x00007fff9303afa4) + 93 at SPTSenTestInvocation.m:16
frame #23: 0x00000001007d2a05 SenTestingKit`-[SenTestCase invokeTest] + 164
frame #24: 0x00000001007d2b7f SenTestingKit`-[SenTestCase performTest:] + 173
frame #25: 0x00000001006c11ab RiverTests`-[SPTSenTestCase performTest:](self=0x00000001020e04a0, _cmd=0x00000001007d87f4, run=0x000000010055bb30) + 123 at SPTSenTestCase.m:127
frame #26: 0x00000001007d2453 SenTestingKit`-[SenTest run] + 65
frame #27: 0x00000001007d5dc1 SenTestingKit`-[SenTestSuite performTest:] + 125
frame #28: 0x00000001007d2453 SenTestingKit`-[SenTest run] + 65
frame #29: 0x00000001007d5dc1 SenTestingKit`-[SenTestSuite performTest:] + 125
frame #30: 0x00000001007d2453 SenTestingKit`-[SenTest run] + 65
frame #31: 0x00000001007d5dc1 SenTestingKit`-[SenTestSuite performTest:] + 125
frame #32: 0x00000001007d2453 SenTestingKit`-[SenTest run] + 65
frame #33: 0x00000001007d4b18 SenTestingKit`+[SenTestProbe runTests:] + 134
frame #34: 0x00007fff88edc395 Foundation`__NSFireDelayedPerform + 358
frame #35: 0x00007fff9012f804 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
frame #36: 0x00007fff9012f31d CoreFoundation`__CFRunLoopDoTimer + 557
frame #37: 0x00007fff90114ad9 CoreFoundation`__CFRunLoopRun + 1529
frame #38: 0x00007fff901140e2 CoreFoundation`CFRunLoopRunSpecific + 290
frame #39: 0x00007fff8a660eb4 HIToolbox`RunCurrentEventLoopInMode + 209
frame #40: 0x00007fff8a660b94 HIToolbox`ReceiveNextEventCommon + 166
frame #41: 0x00007fff8a660ae3 HIToolbox`BlockUntilNextEventMatchingListInMode + 62
frame #42: 0x00007fff92804563 AppKit`_DPSNextEvent + 685
frame #43: 0x00007fff92803e22 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
frame #44: 0x00007fff927fb1d3 AppKit`-[NSApplication run] + 517
frame #45: 0x00007fff9279fc06 AppKit`NSApplicationMain + 869
frame #46: 0x0000000100001842 River`main(argc=8, argv=0x00007fff5fbff6d8) + 34 at main.m:13
frame #47: 0x00007fff93aed7e1 libdyld.dylib`start + 1
The top of these look like the same issue. Is this a problem in my code somewhere (I don't know where it would be) or is there some way to mitigate the issue?
I've tried the typical debugging tips like turning on zombie objects and printing out the contents of the registers when it crashes, neither of those help at all. The registers appear to contain garbage, and having zombies enabled doesn't give any information.
What version of Xcode are you using? I remember seeing something like this when using code coverage with unit tests, but it was fixed in Xcode 4.6. I believe it could be worked around before that by using GCC instead of Clang, but that may or may not be feasible.
From what I can tell, the actual segfault is caused because target->isa is NULL.
To me this suggests memory overwriting. I would try enabling guard malloc (SO question on how to do that) in hopes of catching something writing past the end of a buffer.
I am trying to debug an ipad application I have just inherited from some other developers. At the moment I'm getting a really odd error that I'm not sure how to attack.
The app dies with this error:
* Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSCFSet: 0xc5d2b40> was mutated while being enumerated.'
When I do po 0xc5d2b40, it tells me that its an array of a certain object type. However when I turn on breakpoints at all exceptions and go through the backtrace, there is no sign of an array of this object type being either enumerated or mutated.
I have seen a few references that suggest that this could be related to coredata and multithreading, but I'm wondering if anyone has any suggestions on how to approach this problem. I should also note: I ONLY get this error on the device, NOT in the simulator.
Thanks in advance!
Note: When the app hits the breakpoint from the objc_exception_throw, using the bt command I get the following results from the various background threads:
Most threads look like this:
tid = 0x2c03, 0x307e9cd4 libsystem_kernel.dylib__workq_kernreturn + 8
frame #0: 0x307e9cd4 libsystem_kernel.dylib__workq_kernreturn + 8
frame #1: 0x32d35f3c libsystem_c.dylib_pthread_wqthread + 616
frame #2: 0x32d35cd0 libsystem_c.dylibstart_wqthread + 8
I have one thread which is running a method in the AFURLConnectionOperation (external library: AFNetworking).
There is a single thread with my code in the backtrace, which is what I referenced above. I'm a bit new to the debugger, am I potentially doing something wrong in checking my backtraces?
The backtrace on the thread where all my code is executing looks like this:
tid = 0x2003, 0x32d2fcac libsystem_c.dylib`OSSpinLockLock$VARIANT$wfe + 84
frame #0: 0x32d2fcac libsystem_c.dylib`OSSpinLockLock$VARIANT$wfe + 84
frame #1: 0x32eb7c88 libobjc.A.dylib`_objc_rootReleaseWasZero_slow + 28
frame #2: 0x32eb5210 libobjc.A.dylib`_objc_rootReleaseWasZero + 132
frame #3: 0x32eb515c libobjc.A.dylib`_objc_rootRelease + 12
frame #4: 0x31ba6b0a CoreData`-[NSSQLIntermediate _generateSQLForKeyPathExpression:allowToMany:inContext:] + 278
frame #5: 0x31ba687a CoreData`-[NSSQLIntermediate _generateSQLForExpression:allowToMany:inContext:] + 186
frame #6: 0x31babea4 CoreData`-[NSSQLSimpleWhereIntermediate _generateSQLType2InContext:] + 660
frame #7: 0x31ba6260 CoreData`-[NSSQLSimpleWhereIntermediate generateSQLStringInContext:] + 400
frame #8: 0x31bbbd06 CoreData`-[NSSQLCompoundWhereIntermediate _generateMulticlauseStringInContext:] + 174
frame #9: 0x31bbba84 CoreData`-[NSSQLCompoundWhereIntermediate generateSQLStringInContext:] + 272
frame #10: 0x31ba5d1a CoreData`-[NSSQLFetchIntermediate generateSQLStringInContext:] + 90
frame #11: 0x31ba24d0 CoreData`-[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 460
frame #12: 0x31ba2212 CoreData`-[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 414
frame #13: 0x31ba1e6c CoreData`-[NSSQLCore newRowsForFetchPlan:] + 144
frame #14: 0x31ba152e CoreData`-[NSSQLCore objectsForFetchRequest:inContext:] + 698
frame #15: 0x31ba0fc6 CoreData`-[NSSQLCore executeRequest:withContext:error:] + 282
frame #16: 0x31ba0464 CoreData`-[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1432
frame #17: 0x31b9ec28 CoreData`-[NSManagedObjectContext executeFetchRequest:error:] + 604
frame #18: 0x00052956 digidrill`-[DigidrillIncrementalCache executeFetchRequest:allNewerThanOrFailure:] + 410 at DigidrillIncrementalCache.m:80
frame #19: 0x0003fbae digidrill`-[DigidrillIncrementalStore(Responders) immutableCacheListResponderBegin:intoArray:inContext:outErr:] + 434 at DigidrillIncrementalStore+Responders.m:253
frame #20: 0x00015ea4 digidrill`-[DigidrillIncrementalStore executeRequest:withContext:error:] + 3836 at DigidrillIncrementalStore.m:157
frame #21: 0x31ba0464 CoreData`-[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1432
frame #22: 0x31b9ec28 CoreData`-[NSManagedObjectContext executeFetchRequest:error:] + 604
frame #23: 0x00018534 digidrill`+[CoreDataExtractor executeSyncFetchRequest:callback:onDispatchQueue:] + 704 at CoreDataExtractor.m:175
frame #24: 0x0001a9a2 digidrill`+[CoreDataExtractor ensureGammaDataExistsForTrack:maxOld:flags:outErr:] + 1234 at CoreDataExtractor.m:363
frame #25: 0x00058670 digidrill`-[XYGraph dataForTrackPlot:] + 632 at XYGraph.m:230
frame #26: 0x0006f7d6 digidrill`__23-[TrackPlot reloadData]_block_invoke_0 + 66 at TrackPlot.m:49
frame #27: 0x344b0c58 libdispatch.dylib`_dispatch_call_block_and_release + 12
frame #28: 0x344b2d0e libdispatch.dylib`_dispatch_queue_drain + 274
frame #29: 0x344b2b74 libdispatch.dylib`_dispatch_queue_invoke$VARIANT$mp + 40
frame #30: 0x344b37e6 libdispatch.dylib`_dispatch_worker_thread2 + 210
frame #31: 0x32d35dfa libsystem_c.dylib`_pthread_wqthread + 294
frame #32: 0x32d35cd0 libsystem_c.dylib`start_wqthread + 8
This guy has a pretty good explanation that solved it for me:
http://www.pixeldock.com/blog/collection-was-mutated-while-being-enumerated-during-coredata-operation-on-background-thread/
Basically the MO context can only be used by the thread on which it was created.