Re: async NSOperation and NSOperationQueue
Re: async NSOperation and NSOperationQueue
- Subject: Re: async NSOperation and NSOperationQueue
- From: John Love <email@hidden>
- Date: Tue, 16 Sep 2008 12:50:06 -0400
+++++
Michael Ash wrote:
When your application becomes unresponsive, pause it in the debugger
and look at the backtraces of all the threads. (You can do this in a
single step by typing "t a a bt" at the debugger console. This is a
shortcut for "thread apply all backtrace".) This should quickly tell
you where it's stuck, and thus hopefully why it's stuck.
+++++
t a a bt looks like it could be a powerful tool, but, Michael, I do
not understand most of the following .. I see some familar stuff, such
as MPWaitOnQueue and most of the listing at the very bottom .. but how
is this trace tell me where the hang is? I do see "Cannot access
memory at address 0x0" with Thread3. Apparently, I've leaked memory
or something rotten??
By the way, I init the Queue within the -init of the app controller.
Then, in another method I go through a 100-count big for-loop, at each
iteration of which I init a new NSInvocationOperation via:
theOp = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(calculateWorksheetRow:) object:nil];
followed by
[theQueue addOperation:theOp];
and then,
[theQueue waitUntilAllOperationsAreFinished];
When each Operation completes, I start over by allocating and init-ing
theOp as above.
Anyway, here's the debugger listing:
2008-09-16 12:27:42.885 Calculate Medical[485:10b] okay, so far
[Session started at 2008-09-16 12:27:46 -0400.]
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33
UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-apple-darwin".Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/johnlove/Documents/XCode/Calculate
Medical - ScriptCtrl - queue/build/Release/Calculate Medical.app/
Contents/MacOS/Calculate Medical', process 485.
(gdb) t a a bt
Thread 14 (process 485 thread 0xa00b):
#0 0x001ef506 in semaphore_timedwait_signal_trap ()
#1 0x0022184f in _pthread_cond_wait ()
#2 0x002230d3 in pthread_cond_timedwait_relative_np ()
#3 0x03f351ba in TSWaitOnConditionTimedRelative ()
#4 0x03f55ecc in MPWaitOnQueue ()
#5 0x02152f40 in TFolderSizeTask::FolderSizeTaskProc ()
#6 0x03f54463 in PrivateMPEntryPoint ()
#7 0x002206f5 in _pthread_start ()
#8 0x002205b2 in thread_start ()
Thread 13 (process 485 thread 0xa51f):
#0 0x001ef506 in semaphore_timedwait_signal_trap ()
#1 0x0022184f in _pthread_cond_wait ()
#2 0x002230d3 in pthread_cond_timedwait_relative_np ()
#3 0x03f351ba in TSWaitOnConditionTimedRelative ()
#4 0x03f55ecc in MPWaitOnQueue ()
#5 0x02152f40 in TFolderSizeTask::FolderSizeTaskProc ()
#6 0x03f54463 in PrivateMPEntryPoint ()
#7 0x002206f5 in _pthread_start ()
#8 0x002205b2 in thread_start ()
Thread 12 (process 485 thread 0xa213):
#0 0x001ef506 in semaphore_timedwait_signal_trap ()
#1 0x0022184f in _pthread_cond_wait ()
#2 0x002230d3 in pthread_cond_timedwait_relative_np ()
#3 0x03f351ba in TSWaitOnConditionTimedRelative ()
#4 0x03f55ecc in MPWaitOnQueue ()
#5 0x02152f40 in TFolderSizeTask::FolderSizeTaskProc ()
#6 0x03f54463 in PrivateMPEntryPoint ()
#7 0x002206f5 in _pthread_start ()
#8 0x002205b2 in thread_start ()
Thread 11 (process 485 thread 0x943b):
#0 0x0023f5e2 in select$DARWIN_EXTSN ()
#1 0x005aa50f in __CFSocketManager ()
#2 0x002206f5 in _pthread_start ()
#3 0x002205b2 in thread_start ()
Thread 10 (process 485 thread 0x8e03):
#0 0x0021ff66 in kevent ()
#1 0x0057449f in __monitor_file_descriptor__ ()
#2 0x002206f5 in _pthread_start ()
#3 0x002205b2 in thread_start ()
Thread 9 (process 485 thread 0x7e23):
#0 0x001ef506 in semaphore_timedwait_signal_trap ()
#1 0x0022184f in _pthread_cond_wait ()
#2 0x002230d3 in pthread_cond_timedwait_relative_np ()
#3 0x03f351ba in TSWaitOnConditionTimedRelative ()
#4 0x03f55ecc in MPWaitOnQueue ()
#5 0x0215891d in TPropertyTask::PropertyTaskProc ()
#6 0x03f54463 in PrivateMPEntryPoint ()
#7 0x002206f5 in _pthread_start ()
#8 0x002205b2 in thread_start ()
Thread 8 (process 485 thread 0x7957):
#0 0x001f668e in __semwait_signal ()
#1 0x00221986 in _pthread_cond_wait ()
#2 0x0022136d in pthread_cond_wait$UNIX2003 ()
#3 0x03f5624f in TSWaitOnCondition ()
#4 0x03f3518e in TSWaitOnConditionTimedRelative ()
#5 0x03f55ecc in MPWaitOnQueue ()
#6 0x02150ff6 in TNodeSyncTask::SyncTaskProc ()
#7 0x03f54463 in PrivateMPEntryPoint ()
#8 0x002206f5 in _pthread_start ()
#9 0x002205b2 in thread_start ()
Thread 7 (process 485 thread 0x6b03):
#0 0x001ef4a6 in mach_msg_trap ()
#1 0x001f6c9c in mach_msg ()
#2 0x0059f0ce in CFRunLoopRunSpecific ()
#3 0x0059fd54 in CFRunLoopRun ()
#4 0x02146038 in
TFSEventsNotificationTask::FSEventsNotificationTaskProc ()
#5 0x03f54463 in PrivateMPEntryPoint ()
#6 0x002206f5 in _pthread_start ()
#7 0x002205b2 in thread_start ()
Thread 6 (process 485 thread 0x621f):
#0 0x001ef4a6 in mach_msg_trap ()
#1 0x001f6c9c in mach_msg ()
#2 0x0059f0ce in CFRunLoopRunSpecific ()
#3 0x0059fd54 in CFRunLoopRun ()
#4 0x02145ebf in TSystemNotificationTask::SystemNotificationTaskProc ()
#5 0x03f54463 in PrivateMPEntryPoint ()
#6 0x002206f5 in _pthread_start ()
#7 0x002205b2 in thread_start ()
Thread 5 (process 485 thread 0x490b):
#0 0x001f668e in __semwait_signal ()
#1 0x00221986 in _pthread_cond_wait ()
#2 0x0022136d in pthread_cond_wait$UNIX2003 ()
#3 0x02823e51 in fe_fragment_thread ()
#4 0x002206f5 in _pthread_start ()
#5 0x002205b2 in thread_start ()
Thread 4 (process 485 thread 0x4817):
#0 0x001f668e in __semwait_signal ()
#1 0x001f650f in nanosleep$UNIX2003 ()
#2 0x001f6456 in usleep$UNIX2003 ()
#3 0x00de4979 in -[NSUIHeartBeat _heartBeatThread:] ()
#4 0x01a86f1d in -[NSThread main] ()
#5 0x01a86ac4 in __NSThread__main__ ()
#6 0x002206f5 in _pthread_start ()
#7 0x002205b2 in thread_start ()
Thread 3 (process 485 thread 0x4703):
#0 0x00000000 in ?? ()
Cannot access memory at address 0x0
Thread 2 (process 485 thread 0x4603):
#0 0x0025907a in __workq_ops ()
#1 0x0025a772 in workqueue_exit ()
#2 0x002590aa in start_wqthread ()
Thread 1 (process 485 thread 0x10b):
#0 0x17477a63 in yylex ()
#1 0x1748813a in TASFlexTokenizer::SetInput ()
#2 0x1746d0dc in TASFlexTokenizer::SetInput ()
#3 0x17487327 in TTermList::Init ()
#4 0x17481cca in TTermEntry::AddToTables ()
#5 0x17482078 in TTermEntry::StoreTerm ()
#6 0x174826db in TTermEntry::ScanData ()
#7 0x174825b0 in TTermEntry::ScanSubList ()
#8 0x17482690 in TTermEntry::DoSubLists ()
#9 0x174826ee in TTermEntry::ScanData ()
#10 0x174825b0 in TTermEntry::ScanSubList ()
#11 0x1748478d in TTerminology::ScanSuiteBody ()
#12 0x17485bf2 in TTerminology::ScanTerminologyHandle ()
#13 0x17485e2a in TTerminology::ScanTerminologyHandleList ()
#14 0x17486079 in RebuildDynamicTerms ()
#15 0x17465116 in ASCompile ()
#16 0x03f8360c in CallComponentFunction ()
#17 0x1745fa9e in AppleScriptComponent ()
#18 0x1747b8e3 in AGenericManager::HandleOSACall ()
#19 0x03f3dded in CallComponentDispatch ()
#20 0x1377e1c3 in OSACompile ()
#21 0x01b6f958 in -[NSAppleScript compileAndReturnError:] ()
#22 0x01b6fc46 in -[NSAppleScript(NSPrivate)
_executeWithMode:andReturnError:] ()
#23 0x01b6fa01 in -[NSAppleScript executeAndReturnError:] ()
#24 0x00004674 in -[ScriptController ExecAppleScript:]
(self=0x1508f000, _cmd=0x5e7a, theScript=0x1) at /Volumes/LaCie Data
HD/XCode/Calculate Medical - ScriptCtrl - queue/ScriptController.m:53
#25 0x000047f4 in -[ScriptController theWorkbookActive]
(self=0x1508f000, _cmd=0x57d0) at /Volumes/LaCie Data HD/XCode/
Calculate Medical - ScriptCtrl - queue/ScriptController.m:142
#26 0x000029bb in -[ExcelController startCalculation]
(self=0x1508f020, _cmd=0x570e) at /Users/johnlove/Documents/XCode/
Calculate Medical - ScriptCtrl - queue/ExcelController.m:340
#27 0x000038dd in -[FileController startCalculation] (self=0x15090910,
_cmd=0x570e) at /Users/johnlove/Documents/XCode/Calculate Medical -
ScriptCtrl - queue/FileController.m:334
#28 0x0000255d in -[MedicalDocument windowControllerDidLoadNib:]
(self=0x15071860, _cmd=0x4399b0, aController=0x15080f10) at /Users/
johnlove/Documents/XCode/Calculate Medical - ScriptCtrl - queue/
MedicalDocument.m:56
#29 0x00de640b in -[NSWindowController _windowDidLoad] ()
#30 0x00d84476 in -[NSWindowController window] ()
#31 0x00d84376 in -[NSWindowController showWindow:] ()
#32 0x00d842b9 in -[NSDocument showWindows] ()
#33 0x0105f04d in -[NSDocumentController
openDocumentWithContentsOfURL:display:error:] ()
#34 0x0108d1d7 in -[NSDocumentController openDocument:] ()
#35 0x00e4fc23 in -[NSApplication sendAction:to:from:] ()
#36 0x00efe660 in -[NSMenu performActionForItemAtIndex:] ()
#37 0x00efe365 in -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:] ()
#38 0x00efdfeb in -[NSMenu performKeyEquivalent:] ()
#39 0x00efc890 in -[NSApplication _handleKeyEquivalent:] ()
#40 0x00e19853 in -[NSApplication sendEvent:] ()
#41 0x00d76e27 in -[NSApplication run] ()
#42 0x00d44030 in NSApplicationMain ()
#43 0x0000244e in start ()
(gdb) _______________________________________________
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