-[__NSCFLocalSessionTask _private_onqueue_didReceiveResponse:] crashes on _NSSetObjectValueAndNotify

Originator:nobrien
Number:rdar://26563651 Date Originated:31-May-2016 03:17 PM
Status:Open Resolved:Won't Fix
Product:iOS Product Version:9.3.1
Classification:Crash/Hang/Data Loss Reproducible:Sometimes
 
Summary:
We have millions of crashes for our users at a rate of 11K crashes per day here:

[Thread 22] Crashed: com.apple.NSURLSession-work
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
> 0 CoreFoundation                 6491755536 CFDictionaryGetValue + 48
  1 Foundation                     6502542636 _NSSetObjectValueAndNotify + 72
  2 CFNetwork                      6499261088 -[__NSCFLocalSessionTask _private_onqueue_didReceiveResponse:] + 32
  3 CFNetwork                      6499255716 -[__NSCFLocalDataTask _onqueue_didReceiveResponse:completion:] + 88
  4 CFNetwork                      6499615184 __61-[__NSCFURLLocalSessionConnection _didReceiveResponse:sniff:]_block_invoke + 92
  5 CFNetwork                      6499609736 -[__NSCFURLLocalSessionConnection withDelegateAndPendingCompletion:] + 128
  6 CFNetwork                      6499615072 -[__NSCFURLLocalSessionConnection _didReceiveResponse:sniff:] + 400
  7 CFNetwork                      6499625136 SessionConnectionLoadable::_loaderClientEvent_DidReceiveResponse(_CFURLResponse*) + 104
  8 CFNetwork                      6500160960 ___ZN19URLConnectionLoader26protocolDidReceiveResponseEP14_CFURLResponse_block_invoke + 44
  9 libdispatch.dylib              6486987964 _dispatch_call_block_and_release + 24
 10 libdispatch.dylib              6486987900 _dispatch_client_callout + 16
 11 libdispatch.dylib              6487037120 _dispatch_queue_drain + 864
 12 libdispatch.dylib              6487003008 _dispatch_queue_invoke + 464
 13 libdispatch.dylib              6487045008 _dispatch_root_queue_drain + 728
 14 libdispatch.dylib              6487044272 _dispatch_worker_thread3 + 112
 15 libsystem_pthread.dylib        6489183344 _pthread_wqthread + 1092
 16 libsystem_pthread.dylib        6489182240 start_wqthread + 4


Repro:
We cannot reproduce locally, we only have crash reports

Notes:
Provide additional information, such as references to related problems, workarounds and relevant attachments.

Comments

KVO

This is a KVO crash. Removing the use of KVO or being far more rigorous improved this crash dramatically.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!