Crash on iOS 16(20A5283p):CFSocketInvalidate + 132

Hi, Apps crashed when GCDAsyncSocket closeWithError,since iOS 16 。

Crash stack like this:

Hardware Model: iPhone10,1 Code Type: ARM-64 (Native) Parent Process: [1]

Date/Time: 2022-06-09 08:59:02.201 +0800 OS Version: 16.0 (20A5283p) Report Version: 104

Last Exception :

0 libsystem_platform.dylib 0x000000021bc1f08c 0x000000021bc19000 + 24716

1 libsystem_platform.dylib 0x000000021bc19898 0x000000021bc19000 + 2200

2 CoreFoundation 0x00000001a4dfa3e0 CFSocketInvalidate + 132

3 CFNetwork 0x00000001a5667830 _CFNetworkErrorGetLocalizedDescription + 307856

4 CoreFoundation 0x00000001a4d55f4c CFArrayApplyFunction + 72

5 CFNetwork 0x00000001a56453ac _CFNetworkErrorGetLocalizedDescription + 167436

6 CoreFoundation 0x00000001a4d5d118 0x00000001a4d49000 + 82200

7 CoreFoundation 0x00000001a4dfa718 CFSocketInvalidate + 956

8 CFNetwork 0x00000001a5651e84 _CFNetworkErrorGetLocalizedDescription + 219364

9 CoreFoundation 0x00000001a4d631d4 0x00000001a4d49000 + 106964

10 *** 0x000000010c1bc490 -[GCDAsyncSocket closeWithError:] + 260

11 *** 0x000000010c1c0b54 -[GCDAsyncSocket doReadEOF] + 360

12 *** 0x000000010c1bf1fc __69-[GCDAsyncSocket setupReadAndWriteSourcesForNewlyConnectedSocket:]_block_invoke + 88

13 libdispatch.dylib 0x00000001a4a330f4 0x00000001a4a2f000 + 16628

14 libdispatch.dylib 0x00000001a4a36584 0x00000001a4a2f000 + 30084

15 libdispatch.dylib 0x00000001a4a49b04 0x00000001a4a2f000 + 109316

16 libdispatch.dylib 0x00000001a4a3a684 0x00000001a4a2f000 + 46724

17 libdispatch.dylib 0x00000001a4a3b2f8 0x00000001a4a2f000 + 49912

18 libdispatch.dylib 0x00000001a4a45ebc 0x00000001a4a2f000 + 93884

19 libsystem_pthread.dylib 0x000000021bc210a8 _pthread_wqthread + 288

If you find problems with an existing product on a recently seeded OS, your first step should be to file a bug about that. And please post your bug number, just for the record.

Having said that, I recommend that you stop using GCDAsyncSocket and switch to Network framework. The technologies underlying GCDAsyncSocket are either deprecated (CFSocketStream) or present solely for compatibility purposes (BSD Sockets).

Share and Enjoy

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

Crash on iOS 16(20A5283p):CFSocketInvalidate + 132
 
 
Q