CFNetwork crash when CFArrayGetCount

**I have encountered a crash with a relatively high frequency, which mainly occurs in the Macos 13 and 12.x system. I can hardly search for other useful information. I hope to get your help

blew is the crash report. **

Crashed Thread: 3 com.apple.NSURLConnectionLoader

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY

VM Region Info: 0 is not in any region. Bytes before following region: 4367548416 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START --->
__TEXT 104538000-1055e8000 [ 16.7M] r-x/r-x SM=COW ...s/MacOS/WORKS

Thread 3 Crashed:: com.apple.NSURLConnectionLoader 0 CoreFoundation 0x1ab5966ac CFArrayGetCount + 16 1 CoreFoundation 0x1ab5cfab0 _CFStreamClose + 264 2 CFNetwork 0x1b03928f4 0x1b0177000 + 2210036 3 libdispatch.dylib 0x1ab36a1c8 _dispatch_client_callout + 20 4 libdispatch.dylib 0x1ab36dc64 _dispatch_block_invoke_direct + 264 5 CFNetwork 0x1b01b7180 0x1b0177000 + 262528 6 CoreFoundation 0x1ab5baff8 CFArrayApplyFunction + 84 7 CFNetwork 0x1b01b7070 0x1b0177000 + 262256 8 CFNetwork 0x1b01b6f18 0x1b0177000 + 261912 9 CoreFoundation 0x1ab5fa9a0 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 10 CoreFoundation 0x1ab5fa8ec __CFRunLoopDoSource0 + 208 11 CoreFoundation 0x1ab5fa5ec __CFRunLoopDoSources0 + 268 12 CoreFoundation 0x1ab5f8f6c __CFRunLoopRun + 828 13 CoreFoundation 0x1ab5f8490 CFRunLoopRunSpecific + 600 14 CFNetwork 0x1b03e194c 0x1b0177000 + 2533708 15 Foundation 0x1ac4cd71c NSThread__start + 808 16 libsystem_pthread.dylib 0x1ab52e26c _pthread_start + 148 17 libsystem_pthread.dylib 0x1ab52908c thread_start + 8

   0x1b0177000 -        0x1b062afff com.apple.CFNetwork (1331.0.7) <cfdb5ccd-a5e9-3e08-ad4f-087f420db6a0> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
Answered by markyin in 734853022

follow is the full crash log.

Accepted Answer

follow is the full crash log.

Looking at your crash report there’s some evidence that this is related to an NSURLSession task that has a streamed body, for example, a task created with -uploadTaskWithStreamedRequest:. Do you do that in your app?

Share and Enjoy

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

@eskimo

thanks for your answer.

we didn't find used a place with -uploadTaskWithStreamedRequest:, but we found a third library that used a httpBodyStream from URLRequest.

so is it the error when third library close the stream?

so is it the error when third library close the stream?

I don’t know. All the info I have is from that crash report, and there’s evidence in that report that streams are involved. Specifically, in the report I see this:

Thread 3 Crashed:: com.apple.NSURLConnectionLoader
0   CoreFoundation    … CFArrayGetCount + 16
1   CoreFoundation    … _CFStreamClose + 264
2   CFNetwork         … 0x1a1f33000 + 2213464
3   libdispatch.dylib … _dispatch_client_callout + 20

indicating that CFNetwork has called _CFStreamClose (frames 3 and 2), and the only reason I can think of for CFNetwork to be messing with streams is because of a body stream.

Share and Enjoy

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

CFNetwork crash when CFArrayGetCount
 
 
Q