Crash in NetConnection::dequeue When Spawning URLSessionTasks in Loop

I'm encountering a null pointer dereference crash pointing to the internals of CFNetwork library code on iOS. I'm spawning URLSessionTasks at a decently fast rate (~1-5 per second), with the goal being to generate application layer network traffic. I can reliably encounter this crash pointing to NetConnection::dequeue right after a new task has been spawned and had the resume method called.

I suspect that this is perhaps a race condition or some delegate/session object lifecycle bug. The crash appears to be more easily reproduced with a higher rate of spawning URLSessionTasks. I've included the JSON crash file, the lldb stack trace, and the source code of my URLSession(Task) usage.

Answered by DTS Engineer in 882597022

Ah, you’re using FTP.

The FTP support in URLSession is based on CFFTPStream. That has known crashing bugs, and I believe that one of those bugs in causing this crash in URLSession.

I recommend that you stop using FTP. If you can’t stop using FTP, you need to write or acquire your own FTP client rather than relying on Apple’s built-in one. See TN3151 Choosing the right networking API and, for even more details, my On FTP forums post.

Share and Enjoy

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

Ah, you’re using FTP.

The FTP support in URLSession is based on CFFTPStream. That has known crashing bugs, and I believe that one of those bugs in causing this crash in URLSession.

I recommend that you stop using FTP. If you can’t stop using FTP, you need to write or acquire your own FTP client rather than relying on Apple’s built-in one. See TN3151 Choosing the right networking API and, for even more details, my On FTP forums post.

Share and Enjoy

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

Crash in NetConnection::dequeue When Spawning URLSessionTasks in Loop
 
 
Q