views:

45

answers:

2

Hi, I'm creating images using an NSOperation subclass; threads are spawned to create the images which are displayed in an imageView. The images are set as a key in an arraycontroller, which is bound to the imageview.

Users are randomly reporting the app crashes and the crash log is showing an error in a thread calling the selector _cacheSnapshotRep(); I've been unable to reproduce this myself and there's nothing coming up in web searches for this error.

Here are the relevant sections from the crash log:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  5  Dispatch queue: com.apple.root.default-priority

Application Specific Information:
objc_msgSend() selector name: _cacheSnapshotRep:

And:

Thread 5 Crashed:  Dispatch queue: com.apple.root.default-priority
0   libobjc.A.dylib                 0x90008edb objc_msgSend + 27
1   com.apple.AppKit                0x962abd48 -[NSImage _usingBestRepresentationForRect:context:hints:body:] + 189
2   com.apple.AppKit                0x962ab87e -[NSImage drawInRect:fromRect:operation:fraction:respectFlipped:hints:] + 1939
3   com.apple.AppKit                0x962aa6a0 -[NSImage _drawMappingAlignmentRectToRect:withState:backgroundStyle:operation:fraction:flip:hints:] + 842
4   com.apple.AppKit                0x963bfb95 -[NSImageCell drawInteriorWithFrame:inView:] + 821
5   com.apple.AppKit                0x963bf7f9 -[NSImageCell drawWithFrame:inView:] + 2133
6   com.apple.AppKit                0x9635066a -[NSControl drawRect:] + 589
7   com.apple.AppKit                0x96348a99 -[NSView _drawRect:clip:] + 3510
8   com.apple.AppKit                0x969ae107 -[_NSViewDrawOperation main] + 257
9   com.apple.Foundation            0x9279c33b -[__NSOperationInternal start] + 811
10  com.apple.Foundation            0x9279bf61 ____startOperations_block_invoke_2 + 94
11  libSystem.B.dylib               0x922ac828 _dispatch_call_block_and_release + 16
12  libSystem.B.dylib               0x9229ea5c _dispatch_worker_thread2 + 222
13  libSystem.B.dylib               0x9229e4f1 _pthread_wqthread + 390
14  libSystem.B.dylib               0x9229e336 start_wqthread + 30

I'm a bit lost as to where to go with this from here, so any advice is appreciated.

+2  A: 
Exception Type:  EXC_BAD_ACCESS (SIGBUS)

Looks like a memory management issue to me, NSZombieEnabled or Instruments should aid you in finding what is wrong, especially if you can't reproduce the error yourself.

arul
A: 

So it's looking like it's caused by using non-thread safe classes in my sub-threads.

Apple's documentation gives a nice summary of the thread safety rules.

Benedict Lowndes