Crash in connection loader from CFNetwork with stack traces referring to internal Apple SDKs

We found there is a significant crash reports (most of them are from iOS 17, the rest are iOS 16 and 15) comes from network loader from CFNetwork. Apparently it seems there are two types of crashes if we checked from the stack trace, the one we found from both Xcode organizer and 3rd party crash reporter is referring to URLConnectionLoader::loadWithWhatToDo and the other one from our 3rd party crash reporter (didn’t found the report from Xcode organizer) referring to _CFURLResponseCreateFromArchiveList (this one only happened on iOS 17.5 and later devices). It seems that they are both kinda similar which might point to the same root cause.

From what I’ve seen, we never touch the lower level API directly, we usually use the URLSession to manage our API request. The crashed stack trace also didn’t give any indication about which of our app code that triggered the crash, it only shows calls to Apple’s internal SDKs so we are unsure how to approach this issue meanwhile the crash event already reached 800+ in the last 30 days. Unfortunately, we cannot reproduce the issue as the stack trace itself seems unclear to us.

I have submitted a report through feedback assistant with number: FB14679252.

Would appreciate if anyone can give any advice on what we can do to avoid this in the future and probably any hint on why it could happened.

Hereby I attached the crash reports that we found each from Xcode crash report and our 3rd party crash reporter (the report said it crashed on com.apple.CFNetwork.LoaderQ) so you could get a glimpse of the similarity.

Xcode crash report

3rd party crash report

Answered by DTS Engineer in 799040022
We also never call CFNetwork APIs directly either.

Understood. It’s likely that you call URLSession, or something layered on top of that, like WKWebView. CFNetwork is where most of the implementation for URLSession actually resides.

Notably, I don’t expect that implementation to use CFHost because that DNS work is done by an even lower level, the code that forms the backing for Network framework.

Filing a bug about this is probably your best path forward here, and you’ve already done that (FB14679252), so thanks!

Share and Enjoy

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

Do you have any JSON crash reports for this? That is, any .ips files. If you do, please post one here, or add it to your bug report and let me know here.

This crash is very similar to the one discussed here. Unfortunately, that thread doesn’t have a great resolution. We’ve definitely fixed some bugs that result in crashes like this, but that’s obviously not the full story.

Your third-party crash report references CFHost. Are you calling that directly?

Share and Enjoy

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

Do you have any JSON crash reports for this? That is, any .ips files. If you do, please post one here, or add it to your bug report and let me know here.

Unfortunately, we don't.

This crash is very similar to the one discussed here. Unfortunately, that thread doesn’t have a great resolution. We’ve definitely fixed some bugs that result in crashes like this, but that’s obviously not the full story.

I see, so something similar did happen in the past already.

Your third-party crash report references CFHost. Are you calling that directly?

No, I've checked and found no reference to CFHost in our codebase. We also never call CFNetwork APIs directly either.

Accepted Answer
We also never call CFNetwork APIs directly either.

Understood. It’s likely that you call URLSession, or something layered on top of that, like WKWebView. CFNetwork is where most of the implementation for URLSession actually resides.

Notably, I don’t expect that implementation to use CFHost because that DNS work is done by an even lower level, the code that forms the backing for Network framework.

Filing a bug about this is probably your best path forward here, and you’ve already done that (FB14679252), so thanks!

Share and Enjoy

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

Ahh, thanks for sharing that !

Well, I guess it's clear now that we can only wait for the update on our bug report or see if future iOS version will include the fix.

I appreciate the help given, thanks !

Crash in connection loader from CFNetwork with stack traces referring to internal Apple SDKs
 
 
Q