Crash in release, but not debug - macos

I am writing an app that uses Audio Queue Services to play music. When it gets to the end of one song, it should move on to the next. It works fine in the debug scheme, but it crashes in the release scheme
Process: xxx [1136]
Path: /Users/USER/Desktop/btunes.app/Contents/MacOS/xxx
Identifier: xxx
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: launchd [152]
Responsible: xxx [1136]
User ID: 501
Date/Time: 2014-03-18 09:33:15.557 -0700
OS Version: Mac OS X 10.9.2 (13C64)
Report Version: 11
Anonymous UUID: 57FFD284-4D30-889E-73D0-CE978BAFC774
Crashed Thread: 6 com.apple.coreaudio.AQClient
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000280000018
VM Regions Near 0x280000018:
CG shared images 00000001c7eb2000-00000001c7eba000 [ 32K] r--/r-- SM=SHM
-->
JS JIT generated code 00005b8cc8000000-00005b8cc8001000 [ 4K] ---/rwx SM=NUL
Application Specific Information:
objc_msgSend() selector name: delegate
Thread 6 Crashed:: com.apple.coreaudio.AQClient
0 libobjc.A.dylib 0x00007fff85742097 objc_msgSend + 23
1 com.cluttered.btunes 0x000000010aced249 -[BTSAudioStreamer handleAudioQueueProperty] + 136 (BTSAudioStreamer.m:180)
2 com.apple.audio.toolbox.AudioToolbox 0x00007fff87af6f6d ClientAudioQueue::PropertyChanged(unsigned int) + 415
3 com.apple.audio.toolbox.AudioToolbox 0x00007fff87afc97c AQClientCallbackMessageReader::DispatchCallbacks(void const*, unsigned long) + 440
4 com.apple.audio.toolbox.AudioToolbox 0x00007fff87af742e ClientAudioQueue::FetchAndDeliverPendingCallbacks(unsigned int) + 334
5 com.apple.audio.toolbox.AudioToolbox 0x00007fff87af7554 AQCallbackReceiver_CallbackNotificationsAvailable + 129
6 com.apple.audio.toolbox.AudioToolbox 0x00007fff87b1777c _XCallbackNotificationsAvailable + 48
7 com.apple.audio.toolbox.AudioToolbox 0x00007fff87b111bf mshMIGPerform + 153
8 com.apple.CoreFoundation 0x00007fff81adc9a9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
9 com.apple.CoreFoundation 0x00007fff81adc91e __CFRunLoopDoSource1 + 478
10 com.apple.CoreFoundation 0x00007fff81acda16 __CFRunLoopRun + 1830
11 com.apple.CoreFoundation 0x00007fff81acd0b5 CFRunLoopRunSpecific + 309
12 com.apple.audio.toolbox.AudioToolbox 0x00007fff87afe479 GenericRunLoopThread::Entry(void*) + 187
13 com.apple.audio.toolbox.AudioToolbox 0x00007fff87ab7c0d CAPThread::Entry(CAPThread*) + 109
14 libsystem_pthread.dylib 0x00007fff87db1899 _pthread_body + 138
15 libsystem_pthread.dylib 0x00007fff87db172a _pthread_start + 137
16 libsystem_pthread.dylib 0x00007fff87db5fc9 thread_start + 13
Line 180 is
if (self.delegate) {
The delegate is (weak), and I set self.delegate to nil in dealloc. It looks like the Audio Queue Property Listener keeps running even after I remove it (which I'm also doing in dealloc).
I don't understand why it only happens in Release mode though. For now I'm just archiving the app in Debug but this obviously not ideal. Any ideas?

Paraphrasing/Quoting this post so that the knowledge is retained.
Looks like there is an issue with different optimization levels. Running with optimization at fast causes a crash in some environments.
"One of the differences that jumped out at me was the Optmization Level setting. The Debug version was set to None [-O0], while the Release version was set to Fastest, Smallest [-Os].
I changed the Debug setting to Fastest, Smallest [-Os] and BOOM, it crashed on the iPhone 3G every time I ran it. Switching it back to None [-O0] brought back the correct behavior."
Also see Related SO Question.

Related

How to build a DEXT that works on both Big Sur and Monterey

We are facing a bit of a conundrum in our DriverKit extension development. We would like to build and debug on Monterey. This means that we need to use Xcode 13. We also need to support Big Sur. Unfortunately we haven't been able to build a DEXT with Xcode 13 that works on Big Sur.
We are setting the DRIVERKIT_DEPLOYMENT_TARGET to 19 (the lowest possible value). The DEXT loads fine on Big Sur but whenever a user client connects the DEXT process crashes with an assertion failure like this:
Crashed Thread: 0 Dispatch queue: Root
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
dyld2 mode
abort() called
Thread 0 Crashed:: Dispatch queue: Root
0 libsystem_kernel.dylib 0x0000000104bfb3a4 __pthread_kill + 8
1 libsystem_pthread.dylib 0x0000000104de6844 pthread_kill + 272
2 libsystem_c.dylib 0x0000000104b98f24 abort + 124
3 com.apple.DriverKit 0x00000001048b12b4 __assert_rtn + 92
4 com.apple.DriverKit 0x00000001048b151c OSMetaClassBase::QueueForObject(unsigned long long) (.cold.2) + 44
5 com.apple.DriverKit 0x0000000104893068 OSMetaClassBase::QueueForObject(unsigned long long) + 176
6 com.apple.DriverKit 0x0000000104893780 OSMetaClassBase::Invoke(IORPC) + 412
7 com.apple.DriverKit 0x000000010489425c Server(void*, mach_msg_header_t*, mach_msg_header_t*) + 512
8 com.apple.DriverKit 0x00000001048959c8 uiomachchannel(void*, dispatch_mach_reason_t, dispatch_mach_msg_s*, int) + 156
9 libdispatch.dylib 0x0000000104a43b90 _dispatch_mach_msg_invoke + 476
10 libdispatch.dylib 0x0000000104a313ec _dispatch_lane_serial_drain + 308
11 libdispatch.dylib 0x0000000104a448f4 _dispatch_mach_invoke + 464
12 libdispatch.dylib 0x0000000104a313ec _dispatch_lane_serial_drain + 308
13 libdispatch.dylib 0x0000000104a32154 _dispatch_lane_invoke + 456
14 libdispatch.dylib 0x0000000104a33408 _dispatch_workloop_invoke + 1680
15 libdispatch.dylib 0x0000000104a3c9f0 _dispatch_workloop_worker_thread + 764
16 libsystem_pthread.dylib 0x0000000104de75e0 _pthread_wqthread + 276
17 libsystem_pthread.dylib 0x0000000104dee7fc start_wqthread + 8
I've seen a similar problem on the Apple developer forums and the advice seems to be "upgrade to Monterey", which doesn't help much.
I have not been able to locate any meaningful assertion message. I tried digging in the XNU sources to find the failing assert, but did not have any luck.
Has anyone been able to build a DEXT with Xcode 13 that works on Big Sur? Any pointers on what to try are very welcome.
We faced the same issue, Apple suggested to do a seperate release for both Monterey and BigSur, or do two builds and modify the installer to install based on the corresponding OS.

macbook pro google earth crashes on load, have never been able to use google earth

for over year now i have never been able to use google earth on this mac. as soon as google earth loads up it crashes....
OSX El Capital v 10.11.4
macbook pro retina 15 inch mid 2014
2.5ghz intel core i7
16gb 1600 mhz ddr3
nvidia geforce gt 750m 2048 mb
applicable part of the crash report is thread 0...
Process: Google Earth [41056]
Path: /Applications/Google Earth.app/Contents/MacOS/Google Earth
Identifier: com.Google.GoogleEarthPlus
Version: 7.1 (7.1.5.1557)
Code Type: X86 (Native)
Parent Process: ??? [1]
Responsible: Google Earth [41056]
User ID: 501
Date/Time: 2016-04-10 16:18:18.838 -0700
OS Version: Mac OS X 10.11.4 (15E65)
Report Version: 11
Anonymous UUID: 1504F42B-E3E3-6AC4-511B-68A2A53D901F
Sleep/Wake UUID: 435353B3-973A-430D-8186-3DD791EB15B5
Time Awake Since Boot: 320000 seconds
Time Since Wake: 1400 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000002d998a
Exception Note: EXC_CORPSE_NOTIFY
VM Regions Near 0x2d998a:
__LINKEDIT 0000000000005000-0000000000006000 [ 4K] r--/rwx SM=COW /Applications/Google Earth.app/Contents/MacOS/Google Earth
--> __TEXT 0000000000006000-0000000002112000 [ 33.0M] r-x/rwx SM=COW /Applications/Google Earth.app/Contents/Frameworks/libgoogleearth_free.dylib
__DATA 0000000002112000-00000000021ec000 [ 872K] rw-/rwx SM=COW /Applications/Google Earth.app/Contents/Frameworks/libgoogleearth_free.dylib
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtCore 0x024d633d QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 493
1 QtGui 0x026c615f QDesktopWidget::resizeEvent(QResizeEvent*) + 8543
2 com.apple.CoreFoundation 0x9a73724f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
3 com.apple.CoreFoundation 0x9a714b9b __CFRunLoopDoSources0 + 523
4 com.apple.CoreFoundation 0x9a713fc2 __CFRunLoopRun + 994
5 com.apple.CoreFoundation 0x9a713976 CFRunLoopRunSpecific + 390
6 com.apple.CoreFoundation 0x9a7137db CFRunLoopRunInMode + 123
7 com.apple.HIToolbox 0x9e61f2f1 RunCurrentEventLoopInMode + 267
8 com.apple.HIToolbox 0x9e61efc5 ReceiveNextEventCommon + 201
9 com.apple.HIToolbox 0x9e61eeec _BlockUntilNextEventMatchingListInModeWithFilter + 99
10 com.apple.AppKit 0x938a444e _DPSNextEvent + 1053
11 com.apple.AppKit 0x938a39c7 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1057
12 com.apple.AppKit 0x938a359e -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 121
13 com.apple.AppKit 0x93896cb3 -[NSApplication run] + 1063
14 QtGui 0x026c747a QDesktopWidget::resizeEvent(QResizeEvent*) + 13434
15 QtCore 0x024d1d31 QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 65
16 QtCore 0x024d20fa QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 330
17 QtCore 0x024d6800 QCoreApplication::exec() + 176
18 libgoogleearth_free.dylib 0x000896ba 0x6000 + 538298
19 libgoogleearth_free.dylib 0x00047551 mainMac + 777
20 com.Google.GoogleEarthPlus 0x00002c37 0x1000 + 7223
21 com.Google.GoogleEarthPlus 0x00002775 start + 53
This may be a known issue with cached files, a corrupt myplaces.kml file, or a graphics card that might need updating (unlikely with a MacBook Pro). In any case, Google has a step-by-step troubleshooting guide here:
Google Earth Help: Resolving Crashing and Graphics Issues on a Mac
You may also find the following discussion thread useful. It talks about compatibility issues between certain plugins - specially the fbplugin - which caused a lot of people to experience crashes on startup:
Google Earth crashes on startup
Removed S7PWebVideoPugin.plugin and it works
I had this problem but it was my add blocker. I disable the add blocker and it was fixed. For what it's worth.

phonegap ios App rejected EXC_BAD_ACCESS (SIGSEGV) crashes iPad iOs 7.1.1

I have uploaded the app and it was rejected,
"We found that your app crashed on an iPad running iOS 7.1.1, which is not in compliance with the App Store Review Guidelines.
Your app crashes upon launch."
The app was created with xCode5.1 and latest the Phonegap version. When I uploaded the app, there was no iOS 7.1.1
It seems that there is no Problem running on iPhone, I tried to reproduce the crash but no success.
I updated my iPad Device on 7.1.1 and tested again, no crashes.
Apple's crash report
Incident Identifier: A472D160-FCC9-4D93-959B-396628E53924 CrashReporter Key: 4f2c8fa05c83e9d455c232dbd2fa63e852283d0e
Hardware Model: xxx
Process: HelloWorld [9806]
Path:
/var/mobile/Applications/DE1A86D4-A5B8-40F4-98B8-AC66E235CB5F/HelloWorld.app/HelloWorld
Identifier: com.development.Buch-des-Tages
Version: 1.0.0 (1.0.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2014-04-24 13:36:17.140 -0700 OS Version:
iOS 7.1 (11D167) Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0057005a00240039
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001947c40c0 objc_retain + 32
1 HelloWorld 0x0000000100100db0
-[CDVCommandQueue execute:] + 540
2 HelloWorld 0x0000000100100acc
-[CDVCommandQueue executePending] + 464
3 HelloWorld 0x00000001001007ac
-[CDVCommandQueue enqueCommandBatch:] + 96
4 HelloWorld 0x00000001001008e4
-[CDVCommandQueue fetchCommandsFromJs] + 140
5 HelloWorld 0x0000000100100840
-[CDVCommandQueue maybeFetchCommandsFromJs:] + 128
6 Foundation 0x00000001889545c8
__NSThreadPerformPerform + 324
7 CoreFoundation 0x0000000187d93040
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 20
8 CoreFoundation 0x0000000187d9239c
__CFRunLoopDoSources0 + 252
9 CoreFoundation 0x0000000187d90634 __CFRunLoopRun +
628
10 CoreFoundation 0x0000000187cd16cc
CFRunLoopRunSpecific + 448
11 GraphicsServices 0x000000018d96dc08 GSEventRunModal
+ 164
12 UIKit 0x000000018ae02fd8
UIApplicationMain + 1152
13 HelloWorld 0x0000000100104c90 main (main.m:32)
14 libdyld.dylib 0x0000000194d9fa9c start + 0
Found that Issue at
http://shazronatadobe.wordpress.com/2014/03/12/xcode-5-1-and-cordova-ios/
hoped that solved my Rejection Problem!

Mac App crashes in review due to iCloud, but iCloud cannot be tested locally. What can I do?

I have submitted new version of my app for review for the Mac App Store. The update was rejected because it crashed.
The crash happens when the app disconnects from iCloud. This leads to a strange problem:
The app supports storing files in iCloud and thus includes the iCloud entitlement. An app which uses iCloud and which is signed with a Mac App Store Distribution Profile cannot be launched, because only apps loaded from the App Store are allowed to use iCloud.
Thus I am not able to test the version I submitted on my machine. I can compile an run the app without signing it with a Mac App Store Distribution Profile, but then I cannot use/test iCloud.
I got the CrashLog from the review but I have no idea what the problem might be. Does any one has an idea how to handle this?
Process: MyApp [69811]
Path: /Applications/MyApp.app/Contents/MacOS/MyApp
Identifier: com.example.MyApp
Version: 1.2 (1.2)
App Item ID: 0
App External ID: 0
Code Type: X86-64 (Native)
Parent Process: launchd [184]
Responsible: MyApp [69811]
User ID: 201
Date/Time: 2014-01-29 13:20:22.910 -0800
OS Version: Mac OS X 10.9.1 (13B42)
Report Version: 11
Anonymous UUID: FE66701D-3E78-131A-A6CA-844122FA6616
Sleep/Wake UUID: DF88CF2B-42D1-40BD-BAC7-4C433EC11A34
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff9266ea52 __semwait_signal_nocancel + 10
1 libsystem_c.dylib 0x00007fff8ca39a7c nanosleep$NOCANCEL + 189
2 libsystem_c.dylib 0x00007fff8ca635fe usleep$NOCANCEL + 54
3 libsystem_c.dylib 0x00007fff8ca8fbc4 abort + 135
4 coop.plausible.CrashReporter 0x000000010343030e uncaught_exception_handler + 27
5 com.apple.CoreFoundation 0x00007fff8bc0f8c2 __handleUncaughtException + 706
6 libobjc.A.dylib 0x00007fff8a805304 _objc_terminate() + 94
7 libc++abi.dylib 0x00007fff8e6623e1 std::__terminate(void (*)()) + 8
8 libc++abi.dylib 0x00007fff8e662456 std::terminate() + 54
9 libobjc.A.dylib 0x00007fff8a8050b0 objc_terminate + 9
10 libdispatch.dylib 0x00007fff91e912c1 _dispatch_client_callout + 28
11 libdispatch.dylib 0x00007fff91e98f03 _dispatch_main_queue_callback_4CF + 333
12 com.apple.CoreFoundation 0x00007fff8bb76839 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 com.apple.CoreFoundation 0x00007fff8bb31b14 __CFRunLoopRun + 1636
14 com.apple.CoreFoundation 0x00007fff8bb31275 CFRunLoopRunSpecific + 309
15 com.apple.HIToolbox 0x00007fff93622f0d RunCurrentEventLoopInMode + 226
16 com.apple.HIToolbox 0x00007fff93622cb7 ReceiveNextEventCommon + 479
17 com.apple.HIToolbox 0x00007fff93622abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
18 com.apple.AppKit 0x00007fff875e928e _DPSNextEvent + 1434
19 com.apple.AppKit 0x00007fff875e88db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
20 com.apple.AppKit 0x00007fff875dc9cc -[NSApplication run] + 553
21 com.apple.AppKit 0x00007fff875c7803 NSApplicationMain + 940
22 com.example.MyApp 0x0000000102f92242 0x102f89000 + 37442
23 com.example.MyApp 0x0000000102f8adb4 0x102f89000 + 7604
You can test iCloud enabled apps on your machine during development.
iCloud does require entitlements, signing and provisioning but it also works with development provisioning profiles.
You can use your developer signing ID for debug builds.
Xcode 5 also gained an iCloud debug pane that shows some details about your container and current transfers:

Why might releasing a managed object crash in -[_PFManagedObjectReferenceQueue _queueForDealloc:]?

I am occasionally seeing crashes with a stack trace like this:
0 libobjc.A.dylib 0x97dc0edb objc_msgSend + 27
1 com.apple.CoreData 0x97edcdc2 -[_PFManagedObjectReferenceQueue _queueForDealloc:] + 162
2 com.apple.CoreData 0x97edccbe -[NSManagedObject release] + 94
3 com.apple.CoreFoundation 0x9318ef38 CFRelease + 152
4 com.apple.CoreFoundation 0x931a7460 __CFBasicHashStandardCallback + 384
5 com.apple.CoreFoundation 0x931a706e __CFBasicHashDrain + 478
6 com.apple.CoreFoundation 0x9318f101 _CFRelease + 353
7 com.apple.CoreFoundation 0x931bbc6d _CFAutoreleasePoolPop + 253
8 com.apple.Foundation 0x973270aa NSPopAutoreleasePool + 76
9 com.apple.Foundation 0x97326fd2 -[NSAutoreleasePool drain] + 130
10 com.apple.AppKit 0x95087185 -[NSApplication run] + 627
11 com.apple.AppKit 0x9507f2d9 NSApplicationMain + 574
12 com.karelia.Sandvox 0x70001ef6 start + 54
Unfortunately, it's rather random to reproduce. Does anyone have any ideas what could cause such a crash? Doesn't help that no-one seems to have mentioned -_queueForDealloc: on the internet before!
I have a vague memory of a similar problem in the past where this was a symptom of deallocating a managed object while it still had KVO observers attached. Anyone concur?
Having finally been able to reproduce the problem on a development machine, it seems this crash is a side-effect of an earlier exception during context teardown.
The sequence of events is something like:
The MOC is being deallocated, so it's time to tear down its contents
To do so, all registered MOs are turned into faults*
The act of turning a MO into a fault sends KVO-notifications
An observer receives the notification and tries to act upon it, hitting a now invalid MO in the graph
Core Data throws an exception from the invalid access
For reasons unknown, that exception is not passed to my exception reporter
The MOs get released, but the exception left Core Data in an unexpected state, so the MO deallocation crashes
In short the real problem is that observers outlive the context; don't allow them to! Any object observing a MO should probably also have a strong reference to the MOC, like NSObjectController and friends do.
*I found in testing that Core Data often does this on a background thread, presumably to avoid blocking the main thread
MOC – managed object context
MO – managed object
-_queueForDealloc: is an undocumented internal method. It shows up in stacks from time to time but it's nothing we deal with directly.
Your problem is most likely caused by over-releasing a managedObject. A managedObject will be strongly retained by a context that inserts, updates or changes the object so if you micromanage the objects own retention, you can over-release it prior to the context releasing it. This cause the managed object to disappear at seemingly at random. Conversely, you can over-retain causing an object to persist after the context has deleted it.
I encourage people to avoid retaining managed objects but when you do, put them a class property or a collection like an array or set. That way, the retention is handled for you.
We hit into a a similar issue when using a private managed object context inside an NSOperation and we ended up working around it by weakifying any parameters and using a private #autoreleasepool. I'll elaborate further below.
Our current set up has an NSOperationQueue which has a long running calculation we do in the background. The operation first creates a private managed object context with the parent set as the main object context and goes and fetches its objects.
In the mean time, we have a separate NSOperationQueue elsewhere that syncs down new data from our server, potentially adding, updating, or removing objects used by our calculation operation.
We first saw a bunch of these crashes out in the wild and the only way to repro it locally is to have both calculation and sync operations run continuously and after 5-10 minutes, we would see a crash similar to one of the below:
Thread : Crashed: background queue :: NSOperation 0x18f43c90
0 libobjc.A.dylib 0x36f11f46 objc_msgSend + 5
1 CoreData 0x2928408f -[NSManagedObject release] + 166
2 CoreData 0x2927b4d7 -[_PFArray dealloc] + 94
3 libobjc.A.dylib 0x36f201a9 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 404
4 CoreFoundation 0x294713a9 _CFAutoreleasePoolPop + 16
5 Foundation 0x2a1b6453 -[__NSOperationInternal _start:] + 1058
6 Foundation 0x2a25b44b __NSOQSchedule_f + 186
7 libdispatch.dylib 0x3746d651 _dispatch_queue_drain + 952
8 libdispatch.dylib 0x3746809d _dispatch_queue_invoke + 84
9 libdispatch.dylib 0x3746eba1 _dispatch_root_queue_drain + 320
10 libdispatch.dylib 0x3746fcd7 _dispatch_worker_thread3 + 94
11 libsystem_pthread.dylib 0x375c6e31 _pthread_wqthread + 668
Thread : Crashed: background queue :: NSOperation 0x1db59e80
0 libsystem_kernel.dylib 0x3722edfc __pthread_kill + 8
1 libsystem_pthread.dylib 0x372acd37 pthread_kill + 62
2 libsystem_c.dylib 0x371ce909 abort + 76
3 libsystem_malloc.dylib 0x37258331 szone_size
4 libobjc.A.dylib 0x36bf1621 object_dispose + 20
5 CoreData 0x28ec571d -[_PFManagedObjectReferenceQueue dealloc] + 80
6 CoreData 0x28e5630f -[NSManagedObject dealloc] + 166
7 CoreData 0x28e55217 -[_PFManagedObjectReferenceQueue _queueForDealloc:] + 246
8 CoreData 0x28e5508f -[NSManagedObject release] + 166
9 CoreData 0x28e4c4d7 -[_PFArray dealloc] + 94
10 libobjc.A.dylib 0x36c031a9 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 404
11 CoreFoundation 0x29042149 _CFAutoreleasePoolPop + 16
12 Foundation 0x29d88c23 -[__NSOperationInternal _start:] + 1058
13 Foundation 0x29e2dc1b __NSOQSchedule_f + 186
14 libdispatch.dylib 0x371505b1 _dispatch_queue_drain + 952
15 libdispatch.dylib 0x3714af85 _dispatch_queue_invoke + 84
16 libdispatch.dylib 0x37151b9b _dispatch_root_queue_drain + 338
17 libdispatch.dylib 0x37152cd7 _dispatch_worker_thread3 + 94
18 libsystem_pthread.dylib 0x372a9e31 _pthread_wqthread + 668
Thread : Crashed: NSOperationQueue Serial Queue
0 libsystem_kernel.dylib 0x396871f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x396ef7b7 pthread_kill + 58
2 libsystem_c.dylib 0x39637ff9 abort + 76
3 libsystem_malloc.dylib 0x396aed25 szone_size
4 libobjc.A.dylib 0x390d93a9 object_dispose + 20
5 CoreData 0x2e3d4081 -[_PFManagedObjectReferenceQueue dealloc] + 80
6 CoreData 0x2e3655b7 -[NSManagedObject dealloc] + 166
7 CoreData 0x2e364501 -[_PFManagedObjectReferenceQueue _queueForDealloc:] + 244
8 CoreData 0x2e36437d -[NSManagedObject release] + 164
9 CoreData 0x2e35b867 -[_PFArray dealloc] + 94
10 libobjc.A.dylib 0x390e20d3 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 358
11 CoreFoundation 0x2e5294c1 _CFAutoreleasePoolPop + 16
12 Foundation 0x2ef29999 -[__NSOperationInternal _start:] + 1064
13 Foundation 0x2efcd745 __NSOQSchedule_f + 60
14 libdispatch.dylib 0x395c0cbd _dispatch_queue_drain + 488
15 libdispatch.dylib 0x395bdc6f _dispatch_queue_invoke + 42
16 libdispatch.dylib 0x395c15f1 _dispatch_root_queue_drain + 76
17 libdispatch.dylib 0x395c18dd _dispatch_worker_thread2 + 56
18 libsystem_pthread.dylib 0x396ecc17 _pthread_wqthread + 298
We reviewed the code multiple times and was not able to determine why it was crashing. We tried enabling NSZombies, but would run out of memory long before we could get a repro.
What we ended up doing is the following 2 things:
#autoreleasepool
Inside our [privateObjectContext performBlockAndWait:^{…}] which resides inside our NSOperationBlock, we wrapped all the code inside an #autoreleasepool{…}. That way all NSManagedObjects retrieved during that block of code will be mark for release before leaving the performBlockAndWait.
weakify/strongify
Any parameters that include NSManagedObjects were weakify before passing it into the block, and strongify once in the block. This way since we no longer have a strong reference to them, they can be released if they become out of date while we wait for the NSOperation to start. Here's a good article on how weakify/strongify works: http://aceontech.com/objc/ios/2014/01/10/weakify-a-more-elegant-solution-to-weakself.html
i has another solution so solve that bug. In examples, MOC properties for ARC looks like (readonly,strong,nonatomic)
After weeks of dancing about that time-to-time crash i got solution for osx (just remove nonatomic).
Now it perfect, all crashes go out.

Resources