App Crash in CFNetwork appWasLaunchedForBackgroundSession

We've started to see thousands of crashes on iOS 14.0 (a few on iOS 14.2) when our app is launched for a background session. It looks like CFNetwork is logging something.

Is this a bug in CFNetwork? Has anyone encountered a similar crash?

Code Block language
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000d466bbe9c
VM Region Info: 0xd466bbe9c is not in any region. Bytes after previous region: 45741751965 Bytes before following region: 10629693796
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_NANO 280000000-2a0000000 [512.0M] rw-/rwx SM=PRV
---> GAP OF 0xd20000000 BYTES
commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated)
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [202]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libobjc.A.dylib 0x000000019422b1c0 objc_opt_isKindOfClass + 20 (objc-object.h:260)
1 libsystem_trace.dylib 0x0000000195dd60a4 _os_log_fmt_flatten_object + 816 (format.m:109)
2 libsystem_trace.dylib 0x0000000195de2500 _os_log_impl_flatten_and_send + 1716 (format.c:799)
3 libsystem_trace.dylib 0x0000000195de1e34 _os_log + 152 (log.c:2214)
4 libsystem_trace.dylib 0x0000000195de45e0 _os_log_impl + 12 (log.c:2228)
5 CFNetwork 0x0000000181078dd0 -[NSURLBackgroundSession appWasLaunchedForBackgroundSession:] + 240 (BackgroundSession.mm:0)
6 CoreFoundation 0x0000000180949098 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 20 (CFNotificationCenter.c:706)
7 CoreFoundation 0x0000000180949058 _CFXRegistrationPost_block_invoke + 48 (CFNotificationCenter.c:173)
8 CoreFoundation 0x0000000180948650 _CFXRegistrationPost + 400 (CFNotificationCenter.c:198)
9 CoreFoundation 0x0000000180948048 _CFXNotificationPost + 696 (CFNotificationCenter.c:1071)
10 Foundation 0x0000000181b67b20 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60 (NSNotification.m:575)
11 CFNetwork 0x000000018117bd40 +[NSURLSession _sendPendingCallbacksForSessionIdentifier:] + 64 (Session.mm:222)
12 UIKitCore 0x000000018323e990 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 2932 (UIApplication.m:10283)
13 UIKitCore 0x0000000182750538 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 476 (UIScene.m:1118)
14 UIKitCore 0x0000000182751600 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220 (UIScene.m:1380)
15 UIKitCore 0x0000000182d6ad84 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464 (UIApplicationSceneClientAgent.m:80)
16 FrontBoardServices 0x000000018f2654b0 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 456 (FBSScene.m:547)
17 FrontBoardServices 0x000000018f28dcec 94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 124 (FBSWorkspaceScenesClient.m:533)
18 FrontBoardServices 0x000000018f272410 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 (FBSWorkspace.m:355)
19 FrontBoardServices 0x000000018f28dc38 94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 368 (FBSWorkspaceScenesClient.m:532)
20 libdispatch.dylib 0x000000018061f280 _dispatch_client_callout + 16 (object.m:559)
21 libdispatch.dylib 0x00000001805c4b0c _dispatch_block_invoke_direct$VARIANT$mp + 224 (queue.c:468)
22 FrontBoardServices 0x000000018f2b14b8 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 40 (FBSSerialQueue.m:184)
23 FrontBoardServices 0x000000018f2b1180 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 404 (FBSSerialQueue.m:227)
24 FrontBoardServices 0x000000018f2b1654 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:258)
25 CoreFoundation 0x0000000180966240 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24 (CFRunLoop.c:1967)
26 CoreFoundation 0x0000000180966140 CFRunLoopDoSource0 + 204 (CFRunLoop.c:2011)
27 CoreFoundation 0x0000000180965488 CFRunLoopDoSources0 + 256 (CFRunLoop.c:2048)
28 CoreFoundation 0x000000018095fa40 __CFRunLoopRun + 776 (CFRunLoop.c:2925)
29 CoreFoundation 0x000000018095f200 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3242)
30 GraphicsServices 0x0000000196a5a598 GSEventRunModal + 160 (GSEvent.c:2259)
31 UIKitCore 0x0000000183225004 -[UIApplication _run] + 1052 (UIApplication.m:3270)
32 UIKitCore 0x000000018322a5d8 UIApplicationMain + 164 (UIApplication.m:4739)
33 <app> 0x00000001004853a4 main + 68 (AppDelegate.swift:26)
34 libdyld.dylib 0x000000018063e598 start + 4


Hmmm, that doesn’t look good.

Is this a bug in CFNetwork?

Quite possibly. It’s definitely worth you filing a bug report about it. Please post your bug number, just for the record.

Has anyone encountered a similar crash?

Hard to say without seeing the full crash report. Can you post it here? Please use the text attachment syntax to minimise the impact on the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks! Filed FB8779823 and attached some full crash logs to it.

Filed FB8779823 and attached some full crash logs to it.

Thanks for that. Based on your crash reports it seems that this crash is affecting a wide range of apps, which suggests that it’s not your code but rather a problem with the system itself.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Hey,
Did you get any resolution for this? i'm facing the exact same issue in my app, with exact crash logs line-by-line.
Are you still seeing this on 14.3? Looking at the bug there’s some suggestion that this was fixed there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Yes, i'm still seeing this in 14.3. Checked Firebase and confirmed it.
Thanks, Eskimo. From my side, I no longer see these crashes in 14.3, only 14.2 and below.
App Crash in CFNetwork appWasLaunchedForBackgroundSession
 
 
Q