iOS 15(?) able to break BSD sockets system-wide on some devices

This is a problem that I can repro on one iPhone 12 Pro Max here, and is reported by a few users in the field, but doesn't repro on any other devices here and I can't find a pattern to it (except all user reports so far are on iOS 15). Depending on how widespread it is, it could be pretty bad.

Basically, if you write a simple socket-based app to (in my case) connect to an HTTP server, send a GET request for a very large file, read some bytes of the response, and then close the socket before the download completes, then after one or more iterations of this sequence, it stops working. Specifically, after it "breaks", then subsequently trying to connect a socket to any host at all fails by timing out. It remains "broken" even after killing and relaunching my app. And (here's the scary part) BSD sockets are now "broken" for all other apps on the device and remain broken until you reboot the device. It’s as if the BSD network stack in the OS kernel has fallen over. Really.

Of course I'm preparing to submit an FB including a minimalist sample app that demonstrates the issue. But it seems like a rare occurrence that luckily happens to affect my own phone, so I wanted to see if this sounds familiar to anyone else.

I'm thinking there's nothing an app should be able to do within its own process/sandbox that should affect the behavior of system APIs for other apps and require a reboot to fix. So, yeah.

  • I know, I know. Of course right now I'm scrambling to rewrite this whole thing using the modern Network framework. Just never got around to it before because the old socket-based code has been working great for over 10 years. Until this week, that is.

  • Hi.... We are using BSD Socket code too (For last 9 years) and have recently had some reports (So far only on iPhone 13 and iOS15.x) of sockets not connecting. However it is only a problem when connected on WAN. If user switches to WIFI then everything is OK.

    From your experience with the problem does changing from WAN to Wifi make any difference?

    i'm not sure if what we car seeing could be this issue or something else.

Add a Comment

Replies

I'm thinking there's nothing an app should be able to do within its own process/sandbox that should affect the behavior of system APIs for other apps and require a reboot to fix.

That’s correct [1].

I'm preparing to submit an FB including a minimalist sample app that demonstrates the issue.

That would be much appreciated.

It’s as if the BSD network stack in the OS kernel has fallen over. Really.

Yeah, that’s not too weird. For example, an mbuf leak could cause exactly this problem.

Share and Enjoy

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

[1] Well, an Network Extension provider can completely mess up the device’s networking but that’s not a factor here.

  • Submitted FB9698458.

  • Ta!

Add a Comment

And the smoking gun is... iCloud Private Relay.

If I disable iCloud Private Relay (and reboot if the network stack was already busted) then everything is rock solid.

If I enable iCloud Private Relay, then the severe misbehavior described above will eventually occur. It does seem less bad on iOS 15.1 (the issue takes longer to show up) but it still does occur. I haven’t tested on 15.2 beta yet.

  • Thanks for the update (and I also see that you updated your bug, so thanks fro that as well).

  • Hi @eskimo, could you help correspond this FA ticket FB9801152 related on this issue ? thank you

Add a Comment

could you help correspond this FA ticket FB9801152 related on this issue?

Sorry, but there’s not enough info in your bug report for offer any meaningful advice. However, it’s definitely not related to the issue discussed above because that doesn’t involve a crash (rather, the networking stack just stops making progress).

I recommend that you open a new thread about your issue. Please:

  • Tag it with Network so that I see it.

  • Include a full crash report, per the advice in Posting a Crash Report.

Share and Enjoy

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