CFNetwork Tube Crash

Getting a network crash that looks to be system based, since iOS 11 the crash has came more prevalent. We have tried a number of fixes and investigation but have not found the root cause.


Could I get confirmation

- that this is not a system bug?

- That EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000 is indication of bad block management on our side.


Issue:

Crash on networking call.


Top Trace:

Crashed: com.apple.CFNetwork.Connection EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

0: TubeManager::_onqueue_newTubeReady(Tube*, CFStreamError) + 992


Note:

- Seen on all types of devices

- All crashes say that device has low memory (under 4%), we have investigated this and have fixed some memory leak but issue still happens. We have never seen app use over 200mb of ram.

- We have few a uiwebviews being used.

- We have never been able to reproduce this ourselves

- We have Cert pinning implemented.

- We have one shared NSURLSession object


What we've tried:

- Memory leaks.

- Updated all 3rd party dependences, firebase etc.

- Better webview management. Nil delegate and calling stop loading.


Crash log: (i've hundred of these!)

https://gist.github.com/booranger/17c3a793f6f030555e9c90cc4072addb



Any suggestions on how to debug this issue?


How does one get an iPhone 8 plus to run out of ram!

Replies

Do you have any Apple crash reports for this? If so, please post one. TubeManager is a core component lying at the heart of CFNetwork and thus it will show up in lots of different crash reports (you can look at this thread for some other examples). The best way to tease this apart is with a proper crash report.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Unfortunally we only have access to the logs provided by crashlytics, our customer inform us that there are no crashes reported on itunes connect.


Thanks for your help. I'll update if we find anything of note.


Crashlytics crash report:

https://gist.github.com/booranger/17c3a793f6f030555e9c90cc4072addb

Unfortunally we only have access to the logs provided by crashlytics …

It’s hard for me to keep track of how the various third-party crash reporters are behaving right now, but if your third-party crash reporter is preventing the general of Apple crash reports then you have much bigger problems.

Crashlytics crash report:

Alas this is missing critical information that makes it impossible to analyse problems like this, including:

  • The register state of the crash thread

  • The UUIDs of all the Mach-O images loaded in your process (equivalent to the Binary Images of an Apple crash report)

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

We were able to help the customer and got some logs!

Excellent!

Looking at those crash reports it seems to be very similar to a bug I looked at in detail for another developer (r. 32397611). My conclusion was that the bug was very likely to be a problem in CFNetwork itself, rather than an issue with the client app.

Unfortunately that bug is no longer under active investigation (because we were unable to reproduce it). I recommend that you file your own bug about this, including your crash reports and a reference back to 32397611.

Please post your bug number, just for the record.

I have one question for you. My previous investigations indicated that the bug might be provoked by creating and invalidating a lot of NSURLSession objects. Does your app do that? If it does, you should avoid that. In general NSURLSession objects are intended to be long-lived (see this post for more info on that subject).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Eskimo,


The bug has been filed, the bug number is 34908389 and it was marked as duplicate of 28007668.


We only have one NSURLSession set for all our calls but I can not speak for our 3rd party frameworks unfortunally.


Thanks for your help,

Boo

The bug has been filed, the bug number is 34908389 …

Thanks for that.

We only have one NSURLSession set for all our calls but I can not speak for our 3rd party frameworks unfortunally.

You should be able to determine that by setting symbolic breakpoints on the NSURLSession methods used to create sessions (there’s

+sessionWithConfiguration:
and
+sessionWithConfiguration:delegate:delegateQueue:
). Or, better yet, look for session invalidation with breakpoints on
-finishTasksAndInvalidate
and
-invalidateAndCancel
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi @BooRangerMTT, have you managed to fix this issue, or found some work arounds to reduce the crash rate? Thanks in advance!

It was defiantly an UIWebView issue for us and we eventually found a bit javascript that caused the problem. I think we completely removed Google analytics from the website we were displaying and then it stopped and then started to narrow down the line of code .

Hello,

After removing the google analytics javascript, it resolved your problem ?
I don't understand how it's link with the CFNetwork.Connection

Thank you for your experience

Hi,


I have the same crash in iOS related to:
0x00000001812201c4 ( 0xcc) Tube::_onqueue_errorHandler(CFStreamError) [FUNC, PEXT, NameNList, MangledNameNList, Merged, NList, FunctionStarts]


Crash: https://pastebin.com/YB3rm4bZ


The following are my insights:

- many threads opened in all the crashes

- crashes mainly in devices with slow cpu and low memory: iphone 6, 7

- memory is almost full in the crashes: 2%, 3% of memory

- cannot detect what's the coded that generates the crash: it's in iOS 12, inside *CFNetwork* (CFNetwork`Tube::_onqueue_invokeCB(CFStreamError).

- we follow steps to use Xcode -> Organizer -> Crashes but there were no new information about.

- *our steps now*: using instruments leaks, zombies and memory allocation we are going to suggest how to reduce memory foot print in such devices, because we think it's a problem of resources that should be managed more efficiently in the application (memory, network)


Case ID: 715828880 in Technical Support Incidents (TSIs)


Thanks.


Javier.