Anyone has a clue why I'm experiencing this crash in NSURLSession - ios

Getting a lot of crash reports with this stack trace... unable to fix it.
Had suspicion that it has something to do with me manipulating cookies in the shared instance of NSHTTPCookieStorage, so i have added code to do it on the same thread, but I'm still expiring this.
Any thoughts or ideas will be much appreciated.
Thread 4 Crashed:
0 CoreFoundation 0x23363dc4 CFURLCopyAbsoluteURL + 60
1 CFNetwork 0x22e87039 HTTPCookieStorage::copyCookiesForURL(__CFURL const*, unsigned char) + 74
2 CFNetwork 0x22f65ed1 -[NSHTTPCookieStorage cookiesForURL:] + 90
3 CFNetwork 0x22eef4e1 -[__NSURLBackgroundSession requestWithCookiesApplied:] + 218
4 CFNetwork 0x22ef0505 -[__NSURLBackgroundSession _onqueue_uploadTaskForRequest:uploadFile:bodyData:completion:] + 126
5 CFNetwork 0x22ef03e5 __80-[__NSURLBackgroundSession uploadTaskForRequest:uploadFile:bodyData:completion:]_block_invoke + 38
6 CFNetwork 0x22eefadf __68-[__NSURLBackgroundSession performBlockOnQueueAndRethrowExceptions:]_block_invoke + 84
7 libdispatch.dylib 0x31577c6f _dispatch_client_callout + 20
8 libdispatch.dylib 0x31581559 _dispatch_barrier_sync_f_invoke + 46
9 CFNetwork 0x22eefa0f -[__NSURLBackgroundSession performBlockOnQueueAndRethrowExceptions:] + 208
10 CFNetwork 0x22ef0365 -[__NSURLBackgroundSession uploadTaskForRequest:uploadFile:bodyData:completion:] + 218
11 CFNetwork 0x22f497b7 -[NSURLSession uploadTaskWithRequest:fromFile:] + 32
12 Pogoplug 0x001a3ca5 __46-[CENetworkManager uploadRequest:finishBlock:]_block_invoke (CENetworkManager.m:377)
13 Foundation 0x2414abfd __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 6
14 Foundation 0x240b5ac5 -[NSBlockOperation main] + 146
15 Foundation 0x240a8505 -[__NSOperationInternal _start:] + 766
16 Foundation 0x2414d557 __NSOQSchedule_f + 184
17 libdispatch.dylib 0x315824d3 _dispatch_queue_drain$VARIANT$mp + 1460
18 libdispatch.dylib 0x31581da1 _dispatch_queue_invoke$VARIANT$mp + 82
19 libdispatch.dylib 0x31584491 _dispatch_root_queue_drain + 386
20 libdispatch.dylib 0x315858a3 _dispatch_worker_thread3 + 104
21 libsystem_pthread.dylib 0x316f8da9 _pthread_wqthread + 666
22 libsystem_pthread.dylib 0x316f8afc start_wqthread + 6

Finally found the cause after I managed to reproduce this issue while debugging, and its so silly on my part - its happening when url == nil for upload request.
Not sure why Apple allow to create NSURLMutableRequest with url == nil though, and not throwing exception in [NSMutableURLRequest requestWithURL:] method.

I would suggest check once with Instruments Tool, you will have a clear picture why and where exactly it is crashing.

Related

I am getting this crash, again and again from Crashlytics, but can't reproduce locally

Crashed: com.IPTV.TVLService.GuideProgramService
0 libobjc.A.dylib 0x182a05b90 objc_msgSend + 16
1 CoreFoundation 0x18326f654 CFBasicHashCreateCopy + 668
2 CoreFoundation 0x183291248 CFDictionaryCreateCopy + 148
3 CFNetwork 0x18396fa70 URLResponse::createArchiveList(__CFAllocator const*, long*, void const***, long*) + 228
4 CFNetwork 0x18396f764 URLResponse::copyPropertyList(__CFAllocator const*) + 68
5 CFNetwork 0x1839c1610 ___ZN12__CFURLCache23CreateAndStoreCacheNodeEP16__CFURLCacheNodePK20_CFCachedURLResponsePK10__CFStringPK13_CFURLRequestPKvbRb_block_invoke + 796
6 libdispatch.dylib 0x182dd94bc _dispatch_call_block_and_release + 24
7 libdispatch.dylib 0x182dd947c _dispatch_client_callout + 16
8 libdispatch.dylib 0x182de54c0 _dispatch_queue_drain + 864
9 libdispatch.dylib 0x182ddcf80 _dispatch_queue_invoke + 464
10 libdispatch.dylib 0x182de7390 _dispatch_root_queue_drain + 728
11 libdispatch.dylib 0x182de70b0 _dispatch_worker_thread3 + 112
12 libsystem_pthread.dylib 0x182ff1470 _pthread_wqthread + 1092
13 libsystem_pthread.dylib 0x182ff1020 start_wqthread + 4
I am new to iOS development.
How to understand what's causing issue? Please help me with any document or book that help me to learn solving this issues for future.
It seems like your app crashed in thread com.IPTV.TVLService.GuideProgramService and whether this thread is a custom thread or not?
Are you develop on tvOS?
There is something you should offer to make your question clear.

Camera crash randomly

My app works well the 99% of times but 1% it's crashing after opening the camera, we are getting a random crash. This is the stacktrace from Crashlytics:
Crashed: com.apple.camera.avcapturesession
0 libobjc.A.dylib 0x194d8fbd0 objc_msgSend + 16
1 UIKit 0x1890df21c -[UIViewAnimationState animationForLayer:forKey:forView:] + 712
2 UIKit 0x188e55724 -[UIViewAnimationState actionForLayer:forKey:forView:] + 44
3 UIKit 0x188e19f44 -[UIView(CALayerDelegate) actionForLayer:forKey:] + 140
4 QuartzCore 0x188774e88 -[CALayer actionForKey:] + 104
5 QuartzCore 0x18876a86c actionForKey(CALayer*, CA::Transaction*, NSString*) + 100
6 QuartzCore 0x18876a6d8 CA::Layer::begin_change(CA::Transaction*, unsigned int, objc_object*&) + 176
7 QuartzCore 0x18876d6a0 CA::Layer::setter(unsigned int, _CAValueType, void const*) + 156
8 QuartzCore 0x188774e14 -[CALayer setOpacity:] + 48
9 UIKit 0x188e19a5c -[UIView(Rendering) setAlpha:] + 104
10 corporate 0x1005a3e5c -[GSDK_GTMReadMonitorInputStream .cxx_destruct]
11 corporate 0x1005a4398 -[GSDK_GTMReadMonitorInputStream .cxx_destruct]
12 CoreFoundation 0x184614ae4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
13 CoreFoundation 0x184553220 _CFXNotificationPost + 2060
14 Foundation 0x185452cc0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
15 AVFoundation 0x182efd9c4 -[AVCaptureSession _setRunning:] + 312
16 CameraKit 0x18aac1adc __38-[CAMCaptureController _startPreview:]_block_invoke829
17 libdispatch.dylib 0x1953c13ac _dispatch_call_block_and_release + 24
18 libdispatch.dylib 0x1953c136c _dispatch_client_callout + 16
19 libdispatch.dylib 0x1953cb4c0 _dispatch_queue_drain + 1216
20 libdispatch.dylib 0x1953c4474 _dispatch_queue_invoke + 132
21 libdispatch.dylib 0x1953cd224 _dispatch_root_queue_drain + 664
22 libdispatch.dylib 0x1953ce75c _dispatch_worker_thread3 + 108
23 libsystem_pthread.dylib 0x19559d2e4 _pthread_wqthread + 816
24 libsystem_pthread.dylib 0x19559cfa8 start_wqthread + 4
I don't fully understand where this crash is coming from but I found that I could be related to GoogleNetworkingUtilities.
try this
Are you certain that you aren't doing anything that would effect any UI elements in a background thread?
If you're on iOS 10 you need to add Privacy - Camera Usage Description to your Info.plist file

App crash After core data update on [RKManagedObjectRequestOperation obtainPermanentObjectIDsForInsertedObjects:]

Some users are reporting crashes in my app when I checked it from crittercism. It is giving me below stack trace. I have update my core data with new model version( Using light weight migration). I am using Restkit and Magical Records in my app. I didn't get what is the problem ?
>>0 libobjc.A.dylib 0x353a16ba objc_retain + 8
! 1 Provider 0x00aeb701 __78-[RKManagedObjectRequestOperation obtainPermanentObjectIDsForInsertedObjects:]_block_invoke (RKManagedObjectRequestOperation.m:885)
2 CoreData 0x26c7496b developerSubmittedBlockToNSManagedObjectContextPerform + 180
3 libdispatch.dylib 0x35917c6f _dispatch_client_callout + 20
4 libdispatch.dylib 0x35921559 _dispatch_barrier_sync_f_invoke + 46
5 CoreData 0x26c74857 -[NSManagedObjectContext performBlockAndWait:] + 200
6 Provider 0x00aeb555 -[RKManagedObjectRequestOperation obtainPermanentObjectIDsForInsertedObjects:] (RKManagedObjectRequestOperation.m:882)
7 Provider 0x00ae8c67 __79-[RKManagedObjectRequestOperation performMappingOnResponseWithCompletionBlock:]_block_invoke348 (RKManagedObjectRequestOperation.m:645)
8 Provider 0x00b15961 -[RKResponseMapperOperation willFinish] (RKResponseMapperOperation.m:325)
9 Provider 0x00b1609d -[RKResponseMapperOperation main] (RKResponseMapperOperation.m:412)
10 Foundation 0x27b7cb0d -[__NSOperationInternal _start:] + 766
11 Foundation 0x27c21d93 __NSOQSchedule_f + 184
12 libdispatch.dylib 0x359224d3 _dispatch_queue_drain$VARIANT$mp + 1460
13 libdispatch.dylib 0x35921da1 _dispatch_queue_invoke$VARIANT$mp + 82
14 libdispatch.dylib 0x35924491 _dispatch_root_queue_drain + 386
15 libdispatch.dylib 0x359258a3 _dispatch_worker_thread3 + 104
16 libsystem_pthread.dylib 0x35a99d9d _pthread_wqthread + 666
17 libsystem_pthread.dylib 0x35a99af0 start_wqthread + 6

Thread : Crashed: com.apple.NSURLSession-work

With the release of iOS 8 we've started getting several types of crashes that we've never seen before. Wondering if anyone else has seen this or has any suggestions.
Several of them look similar to this:
Thread : Crashed: com.apple.NSURLSession-work
0 libsystem_kernel.dylib 0x2fd3adfc __pthread_kill + 8
1 libsystem_pthread.dylib 0x2fdb8d37 pthread_kill + 62
2 libsystem_c.dylib 0x2fcda909 abort + 76
3 libsystem_malloc.dylib 0x2fd6b3af szone_error + 334
4 libsystem_malloc.dylib 0x2fd6b637 free_small_botch + 66
5 CFNetwork 0x21a63935 HTTPMessage::ensureParserFinished() + 72
6 CFNetwork 0x21a7aad3 HTTPMessage::copyHeaderFieldValue(__CFString const*) + 18
7 CFNetwork 0x21b43e87 HTTPSniffing::checkRequestAndUpdateResponseForSniffingPurposes(_CFURLRequest const*, _CFURLResponse*) + 130
8 CFNetwork 0x21b15ddd URLConnectionClient::_loaderClientEvent_DidReceiveResponse(_CFURLResponse*) + 340
9 CFNetwork 0x21b1b7d9 ___ZN19URLConnectionLoader26protocolDidReceiveResponseEP14_CFURLResponse_block_invoke + 24
10 CFNetwork 0x21ac9e03 ___ZN20ClassicURLConnection21withLoaderClientAsyncEU13block_pointerFvP21LoaderClientInterfaceE_block_invoke + 14
11 CFNetwork 0x21b14ca9 ___ZNK25URLConnectionInstanceData18withWorkQueueAsyncEU13block_pointerFvvE_block_invoke + 12
12 libdispatch.dylib 0x2fc548cb _dispatch_call_block_and_release + 10
13 libdispatch.dylib 0x2fc5c651 _dispatch_queue_drain + 952
14 libdispatch.dylib 0x2fc5709d _dispatch_queue_invoke + 84
15 libdispatch.dylib 0x2fc5dba1 _dispatch_root_queue_drain + 320
16 libdispatch.dylib 0x2fc5ecd7 _dispatch_worker_thread3 + 94
17 libsystem_pthread.dylib 0x2fdb5e31 _pthread_wqthread + 668
Thanks,
Dan
This is a bug in Apple's code and there is nothing you can do about it, other than wait for an iOS update (or you may want to avoid using the NSURLSession APIs and invoking -[NSURLHTTPResponse allHeaderFields]). But don't hold your horses, it's been there since at least iOS 7.0 and has been reported multiple times (I have done it and my ticket got closed as dupe) and is still not fixed on iOS 8.0.2.
Try updating to the latest AFNetworking 2.5.3.

App crashes in the thread named com.apple.CFURLCACHE_work_queue

My app crashed in the thread named com.apple.CFURLCACHE_work_queue and the crash logs doesn't seem to provide any clues for me to find a bug or mistake =(
Thread 10 name: Dispatch queue: com.apple.CFURLCACHE_work_queue
Thread 10 Crashed:
0 libsystem_kernel.dylib 0x32e93350 __pthread_kill + 8
1 libsystem_c.dylib 0x3b04011e pthread_kill + 54
2 libsystem_c.dylib 0x3b07c96e abort + 90
3 libc++abi.dylib 0x343ebd4a abort_message + 70
4 libc++abi.dylib 0x343e8ff4 default_terminate() + 20
5 libobjc.A.dylib 0x3559fa74 _objc_terminate() + 144
6 libc++abi.dylib 0x343e9078 safe_handler_caller(void (*)()) + 76
7 libc++abi.dylib 0x343e9110 std::terminate() + 16
8 libc++abi.dylib 0x343ea50e __cxa_throw + 118
9 libobjc.A.dylib 0x3559f9ba objc_exception_throw + 90
10 Foundation 0x34d42b60 _NSOutOfMemoryErrorHandler + 56
11 CoreFoundation 0x3725130a __CFDataHandleOutOfMemory + 90
12 CoreFoundation 0x37251458 __CFDataGrow + 288
13 CoreFoundation 0x371d6134 CFDataReplaceBytes + 360
14 CoreFoundation 0x371e3a9a CFDataAppendBytes + 82
15 CFNetwork 0x33150438 CopyAllDataFromDataArray(__CFArray const*) + 104
16 CFNetwork 0x331509ae __CFURLCache::ExecuteSQLInsert(_CFCachedURLResponse const*, __CFString const*, _CFURLRequest const*) + 370
17 CFNetwork 0x3314ec62 __CFURLCache::AddCachedResponseForRequest(__CFURLCacheNode*, _CFCachedURLResponse const*, _CFURLRequest const*) + 58
18 CFNetwork 0x3314eab8 __CFURLCache::ProcessCacheTasks0(bool) + 140
19 CFNetwork 0x3314ea1c __CFURLCache::ProcessCacheTasks(bool) + 32
20 CFNetwork 0x3314e8f0 __CFURLCache::_CFURLCacheTimerCallback0() + 280
21 CFNetwork 0x3314e7c8 __CFURLCache::_CFURLCacheTimerCallback(void*) + 28
22 libdispatch.dylib 0x35f86134 _dispatch_source_invoke$VARIANT$mp + 248
23 libdispatch.dylib 0x35f83e8e _dispatch_queue_drain$VARIANT$mp + 78
24 libdispatch.dylib 0x35f83dbc _dispatch_queue_invoke$VARIANT$mp + 36
25 libdispatch.dylib 0x35f8491a _dispatch_root_queue_drain + 182
26 libdispatch.dylib 0x35f84abc _dispatch_worker_thread2 + 80
27 libsystem_c.dylib 0x3b017a0e _pthread_wqthread + 358
28 libsystem_c.dylib 0x3b0178a0 start_wqthread + 4
any idea or clue of why this happens?
I guess it has something to do with NSURLCache, but I don't manipulate or even create that object in my app.
I'm using Xcode 4.5 GM - I know it's not publicly released yet - and AFNetworking 1.0RC3 for network communication and downloading image data
From the look of things in numbers 10 and 11, it ran out of memory and threw an exception, maybe as part of some kind of assertion.
You will probably find exception information in the console log for the device. If you can connect your device to your Mac, you can access this data in Xcode. Devices don't keep much console data, so it is best to get the log very soon after encountering the error.

Resources