9

I'm seeing the following crash report, but it's not reproducible. How would I go about debugging it? Is this an AFNetworking issue? I'm using version 2.4.1.

Crashed: com.apple.NSURLSession-work
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x0000000000000000

Thread : Crashed: com.apple.NSURLSession-work
0  CoreFoundation                 0x0000000184aad978 CFDictionaryGetValue + 56
1  Foundation                     0x0000000185aa9300 _NSSetLongLongValueAndNotify + 72
2  Foundation                     0x0000000185aa9300 _NSSetLongLongValueAndNotify + 72
3  CFNetwork                      0x0000000184543468 -[__NSCFLocalSessionTask _task_onqueue_didFinish] + 472
4  CFNetwork                      0x0000000184544b38 -[__NSCFLocalSessionTask connection:didFinishLoadingWithError:] + 40
5  CFNetwork                      0x000000018458d030 __46-[__NSCFURLSessionConnection _task_sendFinish]_block_invoke + 136
6  libdispatch.dylib              0x0000000196a49994 _dispatch_call_block_and_release + 24
7  libdispatch.dylib              0x0000000196a49954 _dispatch_client_callout + 16
8  libdispatch.dylib              0x0000000196a540a4 _dispatch_queue_drain + 1448
9  libdispatch.dylib              0x0000000196a4ca5c _dispatch_queue_invoke + 132
10 libdispatch.dylib              0x0000000196a56318 _dispatch_root_queue_drain + 720
11 libdispatch.dylib              0x0000000196a57c4c _dispatch_worker_thread3 + 108
12 libsystem_pthread.dylib        0x0000000196c2922c _pthread_wqthread + 816
soleil
  • 12,133
  • 33
  • 112
  • 183

2 Answers2

6

Yes, it's probably an AFNetworking bug (fixed in 2.5.0), in all likelihood. Specifically, this one:

https://github.com/AFNetworking/AFNetworking/issues/1477

If not, then it is probably something similar—a key-value observer trying to observe some aspect of a URL session task has been deallocated and didn't stop observing that task prior to being deallocated.

dgatwood
  • 10,129
  • 1
  • 28
  • 49
  • 2
    This just happened to me. Using AFNetworking 3.5.1. So I guess it was not fixed? Or regression? – Tom Kraina Nov 03 '16 at 16:18
  • 1
    No idea. Probably another similar bug. It's an easy mistake to make when using KVO. – dgatwood Nov 03 '16 at 18:38
  • Any idea how to debug it? – Tom Kraina Nov 04 '16 at 16:27
  • Look through the code for `addObserver:...` calls and add asserts to ensure that they don't happen on non-main threads. Then make sure each of the observers has a `dealloc` method that calls a `removeObserver:...` method. Finally, look for `removeObserver:...` calls and add similar asserts. If one of the asserts triggers a crash, you've found the culprit. If one of the observers lacked a `removeObserver:...` call, you've found the culprit. – dgatwood Nov 05 '16 at 16:42
  • 1
    Thank You. The funny thing is that I didn't find any usage KVO in my code neither in the open source libs that I'm using. So it crash must be caused by one of the closed source libs. – Tom Kraina Nov 08 '16 at 10:19
  • Worst comes to worst, swizzle the offending class, assuming you can figure out its name. – dgatwood Nov 20 '20 at 14:59
4

I got the same issue and I found it is because I was using Firebase SDK and I upgraded it to 7.0.0,(Although this issue is reported by many developers from > 6.32.1 to 7.0.0) So the firebasePerformance is causing this issue in the first place, which later caused a crash while downloading images using SDWebImage. More information about this issue is here:

firebase/firebase-ios-sdk#6734

Firebase recently fixed this and released a new version for FirebasePerformance (7.0.1) After upgrading to version 7.0.1, I wasn't able to reproduce the crash any longer.

So upgrading of FirebasePerformance SDK to 7.0.1 version worked for me.

Avneesh Agrawal
  • 916
  • 6
  • 11