com.apple.NSURLSession-work EXC_BAD_ACCESS Crash debugging
Asked Answered
H

2

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
Histolysis answered 9/9, 2015 at 23:40 Comment(1)
Note: #40372036Markmarkdown
K
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.

Klaxon answered 16/9, 2015 at 6:53 Comment(6)
This just happened to me. Using AFNetworking 3.5.1. So I guess it was not fixed? Or regression?Blench
No idea. Probably another similar bug. It's an easy mistake to make when using KVO.Klaxon
Any idea how to debug it?Blench
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.Klaxon
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.Blench
Worst comes to worst, swizzle the offending class, assuming you can figure out its name.Klaxon
P
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.

Phylum answered 6/11, 2020 at 10:8 Comment(1)
It seems like link is not working, could you give us a working link? Really want to see what was the issue. Thanks.Girardi

© 2022 - 2024 — McMap. All rights reserved.