Crash in URLConnectionLoader::loadWithWhatToDo

There are multiple report of crashes on URLConnectionLoader::loadWithWhatToDo. The crashed thread in the stack traces pointing to calls inside CFNetwork which seems to be internal library in iOS.

The crash has happened quite a while already (but we cannot detect when the crash started to occur) and impacted multiple iOS versions recorded from iOS 15.4 to 18.4.1 that was recorded in Xcode crash report organizer so far.

Unfortunately, we have no idea on how to reproduce it yet but the crash keeps on increasing and affect more on iOS 18 users (which makes sense because many people updated their iOS to the newer version) and we haven’t found any clue on what actually happened and how to fix it on the crash reports. What we understand is it seems to come from a network request that happened to trigger the crash but we need more information on what (condition) actually cause it and how to solve it.

Hereby, I attach sample crash report for both iOS 15 and 18. I also have submitted a report (that include more crash reports) with number: FB17775979.

Will appreciate any insight regarding this issue and any resolution that we can do to avoid it.

Answered by DTS Engineer in 855533022

Thanks for that.

The crashing code, frame 0 of thread 28, is in _dispatch_source_set_runloop_timer_4CF. I’ve seen this before, and some digging around in my own records points to an issue with CFNetwork (r. 26038149). I originally thought we fixed this back in 2022, but my latest reading of that bug suggests that the fix was not a complete fix. Rather, it was a mitigation that was intended to significantly reduce the occurrences of this crash.

As to what you can do about this, the issue here is a race condition with CFNetwork and there’s nothing you’re doing wrong that’s triggering it. In terms of a workaround, I do have one suggestion for you: Try disabling the classic loading mode by setting the usesClassicLoadingMode property to false. This race condition is in the classic loader, so switching to the modern loader should avoid the issue. However, it’s possible that it might trigger other issues, so make sure to test your product thoroughly before shipping it that way.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Do you have any .ips (JSON format) crash reports?

Also, you’re using a third-party crash reporter (see thread 4 in your first crash report), which isn’t something I generally trust. See Implementing Your Own Crash Reporter for an explanation as to why.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Do you have any .ips (JSON format) crash reports?

Unfortunately, I don't have them.

Also, you’re using a third-party crash reporter (see thread 4 in your first crash report), which isn’t something I generally trust. See Implementing Your Own Crash Reporter for an explanation as to why.

Yes, we use third party crash reporter to help monitor our release in a dashboard but the crash reports I shared here and in the bug report are all coming from Xcode organizer crash reports.

Usually they both have similar stack traces but I think Xcode organizer crash reports is more detailed (like they include Exception Type and Subtype).

Hi, after few months, I haven't been able to solve this yet but apparently our Test Engineer able to reproduce this crash (accidentally) recently so I was able to ask them for the .ips crash report.

I'd like to attach the file here, but I cannot select it as the file seems disabled from the upload menu. Any suggestion ?

I've attached the .ips crash report in FB17775979 since I cannot upload it here.

Hope it can help with the investigation and there is any insight that can be shared with me.

Truly weird crash as it seems we are the only one who faced this issue as I didn't found any other related thread to this yet.

but the crash reports I shared here and in the bug report are all coming from Xcode organizer crash reports.

Right. But the presence of a third-party crash reporter undermines the trustworthiness of Apple crash reports. I talk about this in Implementing Your Own Crash Reporter, and there was a really good (well, bad)-: example of this phenomenon in this recent thread.

I cannot select [the .ips] as the file seems disabled from the upload menu

Sorry about that. This is a known bug. The workaround, as explained in Posting a Crash Report, is to change the extension to .txt and attach that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Right. But the presence of a third-party crash reporter undermines the trustworthiness of Apple crash reports. I talk about this in Implementing Your Own Crash Reporter, and there was a really good (well, bad)-: example of this phenomenon in this recent thread.

I see, thanks for sharing that. I'll look into it in more detail later with the team.

Sorry about that. This is a known bug. The workaround, as explained in Posting a Crash Report, is to change the extension to .txt and attach that.

Got it, I am able to attach the .ips crash report below now, thanks for the workaround.

Accepted Answer

Thanks for that.

The crashing code, frame 0 of thread 28, is in _dispatch_source_set_runloop_timer_4CF. I’ve seen this before, and some digging around in my own records points to an issue with CFNetwork (r. 26038149). I originally thought we fixed this back in 2022, but my latest reading of that bug suggests that the fix was not a complete fix. Rather, it was a mitigation that was intended to significantly reduce the occurrences of this crash.

As to what you can do about this, the issue here is a race condition with CFNetwork and there’s nothing you’re doing wrong that’s triggering it. In terms of a workaround, I do have one suggestion for you: Try disabling the classic loading mode by setting the usesClassicLoadingMode property to false. This race condition is in the classic loader, so switching to the modern loader should avoid the issue. However, it’s possible that it might trigger other issues, so make sure to test your product thoroughly before shipping it that way.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Ahh, that was an interesting explanation.

Thank you for the insight and the suggestion.

We will try it and see how it goes, really appreciate you taking the time to help as always, thank you !

Crash in URLConnectionLoader::loadWithWhatToDo
 
 
Q