Good ways to debug a deadlock (NSOperationQueue at __spin_lock)?
Good ways to debug a deadlock (NSOperationQueue at __spin_lock)?
- Subject: Good ways to debug a deadlock (NSOperationQueue at __spin_lock)?
- From: Rico <email@hidden>
- Date: Mon, 14 Nov 2011 12:20:49 +0100
Hi,
Occasionally users of my app report that the app hangs and uses a lot of CPU. I received a number of process samples that show a similar pattern:
Multiple threads seem to hang at "__spin_lock" while trying to release an NSImage/CGImage (trace below).
Quick summary of what the app does just before the problem happens:
The app creates thumbnail images for files in various folders (via QLThumbnailImageCreate), resizes the images, and displays them. Each thumbnail image is created in a block executed by a single NSOperationQueue instance (concurrently).
Looking at the process sample, is is possible that the various operation blocks somehow lock up on the same image? Each image should only be processed once, but maybe in some underlying API they share a common resource?
Since they all seem to lock up in the AutoreleasePool, should I use my own AutoreleasePool in the block that creates the preview images?
I can't reproduce the problem on my dev system. Any tips what I could to do debug this?
Thanks in advance,
Rico
---------------------------------
Process sample excerpt:
2228 Thread_1384 DispatchQueue_6: com.apple.root.default-priority (concurrent)
2228 start_wqthread
2228 _pthread_wqthread
2228 _dispatch_worker_thread2
2228 _dispatch_call_block_and_release
2228 ____NSOQSchedule_block_invoke_2
2228 -[__NSOperationInternal start]
2228 -[NSBlockOperation main]
2228 0x29ab5
2228 0x225d3
2228 -[NSImage CGImageForProposedRect:context:hints:]
[…] (omitted a few calls)
2228 image_finalize
2228 _CFRelease
2228 image_provider_finalize
2228 ImageProviderReleaseInfoCallback
2228 __spin_lock
2228 Thread_1458 DispatchQueue_6: com.apple.root.default-priority (concurrent)
[…] (similar to below)
2228 Thread_1487 DispatchQueue_6: com.apple.root.default-priority (concurrent)
2228 start_wqthread
2228 _pthread_wqthread
2228 _dispatch_worker_thread2
2228 _dispatch_call_block_and_release
2228 ____NSOQSchedule_block_invoke_2
2228 -[__NSOperationInternal start]
2228 NSPopAutoreleasePool
2228 _CFAutoreleasePoolPop
2228 CFRelease
2228 -[NSImage dealloc]
2228 -[NSImage _deallocAuxiliaryStorage]
2228 -[NSCGImageSnapshotRep dealloc]
2228 _CFRelease
2228 image_finalize
2228 _CFRelease
2228 image_provider_finalize
2228 ImageProviderReleaseInfoCallback
2228 __spin_lock
_______________________________________________
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