Repository navigation
Labels
bugIf an issue is a bug or a pull request a bug fixnetworkingIf an issue or pull request is related to networking
Milestone
Description
Use this test project: #11799 (comment)
Run the project for a while (typically hours, sometimes overnight - at one point it crashed after 16 hours / just over 1.5M network requests), and it eventually crashes.
lldb shows this stack trace:
(lldb) bt
* thread #1, name = 'tid_103', queue = 'com.apple.main-thread', stop reason = signal SIGSEGV
* frame #0: 0x000000019d9e5c34 libobjc.A.dylib`objc_msgSend + 52
frame #1: 0x000000019da18a5c libobjc.A.dylib`objc_object::sidetable_release(bool, bool) + 292
frame #2: 0x00000001a30f169c CFNetwork`___lldb_unnamed_symbol2909 + 32
frame #3: 0x00000001a30f1400 CFNetwork`___lldb_unnamed_symbol2903 + 260
frame #4: 0x000000019dab717c libsystem_blocks.dylib`_call_dispose_helpers_excp + 48
frame #5: 0x000000019dab6f48 libsystem_blocks.dylib`_Block_release + 252
frame #6: 0x00000001a3194e7c CFNetwork`___lldb_unnamed_symbol5273 + 28
frame #7: 0x000000019dab717c libsystem_blocks.dylib`_call_dispose_helpers_excp + 48
frame #8: 0x000000019dab6f48 libsystem_blocks.dylib`_Block_release + 252
frame #9: 0x000000019dc0a3e8 libdispatch.dylib`_dispatch_client_callout + 20
frame #10: 0x000000019dc18bb8 libdispatch.dylib`_dispatch_main_queue_drain + 988
frame #11: 0x000000019dc187cc libdispatch.dylib`_dispatch_main_queue_callback_4CF + 44
frame #12: 0x000000019dedb4ac CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
frame #13: 0x000000019de98c30 CoreFoundation`__CFRunLoopRun + 1996
frame #14: 0x000000019de97e0c CoreFoundation`CFRunLoopRunSpecific + 608
frame #15: 0x00000001a8633000 HIToolbox`RunCurrentEventLoopInMode + 292
frame #16: 0x00000001a8632e3c HIToolbox`ReceiveNextEventCommon + 648
frame #17: 0x00000001a8632b94 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
frame #18: 0x00000001a16f0970 AppKit`_DPSNextEvent + 660
frame #19: 0x00000001a1ee2dec AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
frame #20: 0x00000001a16e3cb8 AppKit`-[NSApplication run] + 476
frame #21: 0x00000001a16baf54 AppKit`NSApplicationMain + 880
frame #22: 0x00000001a190d610 AppKit`_NSApplicationMainWithInfoDictionary + 24
frame #23: 0x00000001b71290dc UIKitMacHelper`UINSApplicationMain + 972
frame #24: 0x00000001cd2159b4 UIKitCore`UIApplicationMain + 148
frame #25: 0x0000000106879854 nsurlsessionhandler`xamarin_UIApplicationMain(argc=0, argv=0x00006000028144c0, principalClassName=0x0000000000000000, delegateClassName="AppDelegate", exception_gchandle=0x000000016fdfe8e0) at bindings.m:126:10
frame #26: 0x00000001065c6280 nsurlsessionhandler`wrapper_managed_to_native_UIKit_UIApplication_xamarin_UIApplicationMain_int_intptr_intptr_intptr_intptr_ + 176
frame #27: 0x0000000105db9614 nsurlsessionhandler`UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 100
frame #28: 0x0000000105db9948 nsurlsessionhandler`UIKit_UIApplication_Main_string___System_Type_System_Type + 280
frame #29: 0x0000000102492d68 nsurlsessionhandler`Program__Main__string__ + 136
frame #30: 0x000000010508ea08 nsurlsessionhandler`wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 296
frame #31: 0x0000000106b8ea90 nsurlsessionhandler`mono_jit_runtime_invoke(method=<unavailable>, obj=<unavailable>, params=<unavailable>, exc=<unavailable>, error=0x000000016fdfec90) at mini-runtime.c:3636:3 [opt]
frame #32: 0x0000000106b2f158 nsurlsessionhandler`mono_runtime_invoke_checked [inlined] do_runtime_invoke(method=0x000000011a914598, obj=0x0000000000000000, params=0x000000016fdfec30, exc=0x0000000000000000, error=0x000000016fdfec90) at object.c:2576:11 [opt]
frame #33: 0x0000000106b2f11c nsurlsessionhandler`mono_runtime_invoke_checked(method=0x000000011a914598, obj=0x0000000000000000, params=0x000000016fdfec30, error=0x000000016fdfec90) at object.c:2792:9 [opt]
frame #34: 0x0000000106b35494 nsurlsessionhandler`mono_runtime_exec_main_checked [inlined] do_exec_main_checked(method=0x000000011a914598, args=<unavailable>, error=0x000000016fdfec90) at object.c:0 [opt]
frame #35: 0x0000000106b35458 nsurlsessionhandler`mono_runtime_exec_main_checked(method=0x000000011a914598, args=<unavailable>, error=0x000000016fdfec90) at object.c:4775:9 [opt]
frame #36: 0x0000000106b35540 nsurlsessionhandler`mono_runtime_run_main_checked(method=<unavailable>, argc=<unavailable>, argv=<unavailable>, error=<unavailable>) at object.c:4339:9 [opt] [artificial]
frame #37: 0x0000000106be1434 nsurlsessionhandler`mono_jit_exec at driver.c:1369:13 [opt]
frame #38: 0x0000000106be1424 nsurlsessionhandler`mono_jit_exec(domain=<unavailable>, assembly=<unavailable>, argc=1, argv=0x000000016fdfed10) at driver.c:1314:7 [opt]
frame #39: 0x00000001068a2e58 nsurlsessionhandler`xamarin_main(argc=1, argv=0x000000016fdff070, launch_mode=XamarinLaunchModeApp) at monotouch-main.m:495:8
frame #40: 0x0000000106d47b18 nsurlsessionhandler`main(argc=1, argv=0x000000016fdff070) at main.arm64.mm:416:11
frame #41: 0x000000019da320e0 dyld`start + 2360
manually symbolicating the stack using backtrace in lldb shows:
(lldb) parray 20 (char **) 0x000000011aa14800
(char **) $1 = 0x000000011aa14800 {
[0] = 0x000000011aa148a0 "0 ??? 0x000000010f58c64c 0x0 + 4552443468"
[1] = 0x000000011aa148ec "1 nsurlsessionhandler 0x0000000106d47ad8 main + 0"
[2] = 0x000000011aa14930 "2 CFNetwork 0x00000001a30f169c CFURLRequestGetMainDocumentURL + 20720"
[3] = 0x000000011aa14992 "3 CFNetwork 0x00000001a30f1400 CFURLRequestGetMainDocumentURL + 20052"
[4] = 0x000000011aa149f4 "4 libsystem_blocks.dylib 0x000000019dab717c _call_dispose_helpers_excp + 48"
[5] = 0x000000011aa14a4f "5 libsystem_blocks.dylib 0x000000019dab6f48 _Block_release + 252"
[6] = 0x000000011aa14a9f "6 CFNetwork 0x00000001a3194e7c CFURLCredentialStorageCopyAllCredentials + 40380"
[7] = 0x000000011aa14b0b "7 libsystem_blocks.dylib 0x000000019dab717c _call_dispose_helpers_excp + 48"
[8] = 0x000000011aa14b66 "8 libsystem_blocks.dylib 0x000000019dab6f48 _Block_release + 252"
[9] = 0x000000011aa14bb6 "9 libdispatch.dylib 0x000000019dc0a3e8 _dispatch_client_callout + 20"
[10] = 0x000000011aa14c0f "10 libdispatch.dylib 0x000000019dc18bb8 _dispatch_main_queue_drain + 988"
[11] = 0x000000011aa14c6b "11 libdispatch.dylib 0x000000019dc187cc _dispatch_main_queue_callback_4CF + 44"
[12] = 0x000000011aa14ccd "12 CoreFoundation 0x000000019dedb4ac __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16"
[13] = 0x000000011aa14d40 "13 CoreFoundation 0x000000019de98c30 __CFRunLoopRun + 1996"
[14] = 0x000000011aa14d91 "14 CoreFoundation 0x000000019de97e0c CFRunLoopRunSpecific + 608"
[15] = 0x000000011aa14de7 "15 HIToolbox 0x00000001a8633000 RunCurrentEventLoopInMode + 292"
[16] = 0x000000011aa14e42 "16 HIToolbox 0x00000001a8632e3c ReceiveNextEventCommon + 648"
[17] = 0x000000011aa14e9a "17 HIToolbox 0x00000001a8632b94 _BlockUntilNextEventMatchingListInModeWithFilter + 76"
[18] = 0x000000011aa14f0b "18 AppKit 0x00000001a16f0970 _DPSNextEvent + 660"
[19] = 0x000000011aa14f5a "19 AppKit 0x00000001a1ee2dec -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700"
}
Some investigation in lldb revelead:
___lldb_unnamed_symbol2909:[__NSCFURLSessionConnection dealloc]___lldb_unnamed_symbol2903:[__NSCFURLLocalSessionConnection dealloc]___lldb_unnamed_symbol5273: a block dispose method
Some more lldb info:
(lldb) disass
CFNetwork`___lldb_unnamed_symbol2909: # [__NSCFURLSessionConnection dealloc]
0x1a30f167c <+0>: pacibsp
0x1a30f1680 <+4>: sub sp, sp, #0x30
0x1a30f1684 <+8>: stp x20, x19, [sp, #0x10]
0x1a30f1688 <+12>: stp x29, x30, [sp, #0x20]
0x1a30f168c <+16>: add x29, sp, #0x20
0x1a30f1690 <+20>: mov x19, x0
0x1a30f1694 <+24>: ldr x0, [x0, #0x8]
0x1a30f1698 <+28>: bl 0x1a3359158 ; symbol stub for: objc_release
-> 0x1a30f169c <+32>: ldr x0, [x19, #0x10]
0x1a30f16a0 <+36>: cbz x0, 0x1a30f16ac ; <+48>
0x1a30f16a4 <+40>: bl 0x1a3357578 ; symbol stub for: dispatch_release
0x1a30f16a8 <+44>: str xzr, [x19, #0x10]
0x1a30f16ac <+48>: mov x0, x19
0x1a30f16b0 <+52>: mov x2, #0x0
0x1a30f16b4 <+56>: mov w3, #0x18
0x1a30f16b8 <+60>: bl 0x1a33591c8 ; symbol stub for: objc_setProperty_atomic
0x1a30f16bc <+64>: ldr x0, [x19, #0x28]
0x1a30f16c0 <+68>: cbz x0, 0x1a30f16cc ; <+80>
0x1a30f16c4 <+72>: bl 0x1a3359158 ; symbol stub for: objc_release
0x1a30f16c8 <+76>: str xzr, [x19, #0x28]
0x1a30f16cc <+80>: ldr x0, [x19, #0x30]
0x1a30f16d0 <+84>: cbz x0, 0x1a30f16dc ; <+96>
0x1a30f16d4 <+88>: bl 0x1a3357578 ; symbol stub for: dispatch_release
0x1a30f16d8 <+92>: str xzr, [x19, #0x30]
0x1a30f16dc <+96>: adrp x8, 424846
0x1a30f16e0 <+100>: ldr x8, [x8, #0x890]
0x1a30f16e4 <+104>: stp x19, x8, [sp]
0x1a30f16e8 <+108>: adrp x8, 373089
0x1a30f16ec <+112>: add x1, x8, #0x71f
0x1a30f16f0 <+116>: mov x0, sp
0x1a30f16f4 <+120>: bl 0x1a33590f8 ; symbol stub for: objc_msgSendSuper2
0x1a30f16f8 <+124>: ldp x29, x30, [sp, #0x20]
0x1a30f16fc <+128>: ldp x20, x19, [sp, #0x10]
0x1a30f1700 <+132>: add sp, sp, #0x30
0x1a30f1704 <+136>: retab
(lldb) disass
CFNetwork`___lldb_unnamed_symbol2903: # [__NSCFURLLocalSessionConnection dealloc]
0x1a30f12fc <+0>: pacibsp
0x1a30f1300 <+4>: sub sp, sp, #0x30
0x1a30f1304 <+8>: stp x20, x19, [sp, #0x10]
0x1a30f1308 <+12>: stp x29, x30, [sp, #0x20]
0x1a30f130c <+16>: add x29, sp, #0x20
0x1a30f1310 <+20>: mov x19, x0
0x1a30f1314 <+24>: adrp x8, 399283
0x1a30f1318 <+28>: ldrsw x20, [x8, #0x414]
0x1a30f131c <+32>: ldr x0, [x0, x20]
0x1a30f1320 <+36>: cbz x0, 0x1a30f134c ; <+80>
0x1a30f1324 <+40>: ldr x16, [x0]
0x1a30f1328 <+44>: mov x17, x0
0x1a30f132c <+48>: movk x17, #0x81be, lsl #48
0x1a30f1330 <+52>: autda x16, x17
0x1a30f1334 <+56>: ldr x8, [x16, #0x8]!
0x1a30f1338 <+60>: mov x9, x16
0x1a30f133c <+64>: mov x17, x9
0x1a30f1340 <+68>: movk x17, #0x990e, lsl #48
0x1a30f1344 <+72>: blraa x8, x17
0x1a30f1348 <+76>: str xzr, [x19, x20]
0x1a30f134c <+80>: adrp x8, 399283
0x1a30f1350 <+84>: ldrsw x20, [x8, #0x410]
0x1a30f1354 <+88>: ldr x0, [x19, x20]
0x1a30f1358 <+92>: cbz x0, 0x1a30f1384 ; <+136>
0x1a30f135c <+96>: ldr x16, [x0]
0x1a30f1360 <+100>: mov x17, x0
0x1a30f1364 <+104>: movk x17, #0x4399, lsl #48
0x1a30f1368 <+108>: autda x16, x17
0x1a30f136c <+112>: ldr x8, [x16, #0x8]!
0x1a30f1370 <+116>: mov x9, x16
0x1a30f1374 <+120>: mov x17, x9
0x1a30f1378 <+124>: movk x17, #0x3f8b, lsl #48
0x1a30f137c <+128>: blraa x8, x17
0x1a30f1380 <+132>: str xzr, [x19, x20]
0x1a30f1384 <+136>: adrp x8, 399283
0x1a30f1388 <+140>: ldrsw x20, [x8, #0x41c]
0x1a30f138c <+144>: ldr x0, [x19, x20]
0x1a30f1390 <+148>: cbz x0, 0x1a30f139c ; <+160>
0x1a30f1394 <+152>: bl 0x1a3359158 ; symbol stub for: objc_release
0x1a30f1398 <+156>: str xzr, [x19, x20]
0x1a30f139c <+160>: adrp x8, 399283
0x1a30f13a0 <+164>: ldrsw x20, [x8, #0x420]
0x1a30f13a4 <+168>: ldr x0, [x19, x20]
0x1a30f13a8 <+172>: cbz x0, 0x1a30f13b4 ; <+184>
0x1a30f13ac <+176>: bl 0x1a3357578 ; symbol stub for: dispatch_release
0x1a30f13b0 <+180>: str xzr, [x19, x20]
0x1a30f13b4 <+184>: adrp x8, 399283
0x1a30f13b8 <+188>: ldrsw x20, [x8, #0x424]
0x1a30f13bc <+192>: ldr x0, [x19, x20]
0x1a30f13c0 <+196>: cbz x0, 0x1a30f13cc ; <+208>
0x1a30f13c4 <+200>: bl 0x1a3357578 ; symbol stub for: dispatch_release
0x1a30f13c8 <+204>: str xzr, [x19, x20]
0x1a30f13cc <+208>: adrp x8, 399283
0x1a30f13d0 <+212>: ldrsw x20, [x8, #0x428]
0x1a30f13d4 <+216>: ldr x0, [x19, x20]
0x1a30f13d8 <+220>: cbz x0, 0x1a30f13e4 ; <+232>
0x1a30f13dc <+224>: bl 0x1a3359158 ; symbol stub for: objc_release
0x1a30f13e0 <+228>: str xzr, [x19, x20]
0x1a30f13e4 <+232>: adrp x8, 424846
0x1a30f13e8 <+236>: ldr x8, [x8, #0x898]
0x1a30f13ec <+240>: stp x19, x8, [sp]
0x1a30f13f0 <+244>: adrp x8, 373089
0x1a30f13f4 <+248>: add x1, x8, #0x71f
0x1a30f13f8 <+252>: mov x0, sp
0x1a30f13fc <+256>: bl 0x1a33590f8 ; symbol stub for: objc_msgSendSuper2
-> 0x1a30f1400 <+260>: ldp x29, x30, [sp, #0x20]
0x1a30f1404 <+264>: ldp x20, x19, [sp, #0x10]
0x1a30f1408 <+268>: add sp, sp, #0x30
0x1a30f140c <+272>: retab
(lldb) disass
CFNetwork`___lldb_unnamed_symbol5273: # block dispose method
0x1a3194e60 <+0>: pacibsp
0x1a3194e64 <+4>: stp x20, x19, [sp, #-0x20]!
0x1a3194e68 <+8>: stp x29, x30, [sp, #0x10]
0x1a3194e6c <+12>: add x29, sp, #0x10
0x1a3194e70 <+16>: mov x19, x0
0x1a3194e74 <+20>: ldr x0, [x0, #0x30]
0x1a3194e78 <+24>: bl 0x1a3359158 ; symbol stub for: objc_release
-> 0x1a3194e7c <+28>: ldr x0, [x19, #0x28]
0x1a3194e80 <+32>: bl 0x1a3359158 ; symbol stub for: objc_release
0x1a3194e84 <+36>: ldr x0, [x19, #0x20]
0x1a3194e88 <+40>: ldp x29, x30, [sp, #0x10]
0x1a3194e8c <+44>: ldp x20, x19, [sp], #0x20
0x1a3194e90 <+48>: autibsp
0x1a3194e94 <+52>: eor x16, x30, x30, lsl #1
0x1a3194e98 <+56>: tbz x16, #0x3e, 0x1a3194ea0 ; <+64>
0x1a3194e9c <+60>: brk #0xc471
0x1a3194ea0 <+64>: b 0x1a3359158 ; symbol stub for: objc_release
(lldb) re re
General Purpose Registers:
x0 = 0x000000011b8b5180
x1 = 0x00000001fe25271f
x2 = 0x0000600003fbe3c0
x3 = 0x0000600003fbe3c0
x4 = 0x0000600003fbe440
x5 = 0x00000000000023c0
x6 = 0x0000000000000000
x7 = 0x0000000000000403
x8 = 0x000000020a5f4e78 "dealloc"
x9 = 0x000000020a5f4e78 "dealloc"
x10 = 0x0000000400000041
x11 = 0x0000000000000000
x12 = 0x0000000000000000
x13 = 0x0000000400000041
x14 = 0x000000011b893ce0
x15 = 0x000000011b893ce0
x16 = 0x000000011b893ce0
x17 = 0x0000000000000001
x18 = 0x0000000000000000
x19 = 0x000000011b8b5180
x20 = 0x0000000000000001
x21 = 0x0000000205ac7400 libobjc.A.dylib`(anonymous namespace)::SideTablesMap + 3072
x22 = 0x0000000000000001
x23 = 0x0000000000000104
x24 = 0x0000000000000000
x25 = 0x0000000205ac7ba0 dyld`_main_thread + 224
x26 = 0x0000600003fbd100
x27 = 0x000000000000000f
x28 = 0x0000000000000000
fp = 0x000000016fdfcea0
lr = 0x000000019da18a5c libobjc.A.dylib`objc_object::sidetable_release(bool, bool) + 292
sp = 0x000000016fdfce50
pc = 0x000000019d9e5c34 libobjc.A.dylib`objc_msgSend + 52
cpsr = 0x20001000
Reacted by mlancione and Jonathan ANTOINE
Reacted by Michał Żołnieruk, Zalkovalsky and dartasen
Metadata
Metadata
Assignees
Labels
bugIf an issue is a bug or a pull request a bug fixnetworkingIf an issue or pull request is related to networking
Activity
tipa commentedon Oct 2, 2024
rolfbjarne commentedon Oct 2, 2024
sleushunou commentedon Feb 28, 2025
rolfbjarne commentedon Feb 28, 2025
mlancione commentedon Apr 22, 2025
Any update on this issue? We are experiencing the same issue even when running the latest .NET 9 release (9.0.203 iOS 18.4.9288).
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000194950790 0x194948000 + 34704
1 CFNetwork 0x000000019897ff3c -[__NSCFURLSessionConnection dealloc] + 32 (SessionConnection.mm:357)
2 CFNetwork 0x000000019897fc94 -[__NSCFURLLocalSessionConnection dealloc] + 260 (SessionConnection.mm:591)
3 libsystem_blocks.dylib 0x0000000222264a20 <deduplicated_symbol> + 68
4 libsystem_blocks.dylib 0x00000002222643e4 HelperBase::destroyBlock(Block_layout*, bool, unsigned char*) + 116 (runtime.cpp:471)
5 libsystem_blocks.dylib 0x0000000222264868 _call_dispose_helpers_excp + 72 (generic_helpers.c:34)
6 libsystem_blocks.dylib 0x0000000222264354 _Block_release + 236 (runtime.cpp:1017)
7 libsystem_blocks.dylib 0x00000002222648e0 <deduplicated_symbol> + 68
8 libsystem_blocks.dylib 0x0000000222264434 HelperBase::destroyBlock(Block_layout*, bool, unsigned char*) + 196 (runtime.cpp:479)
9 libsystem_blocks.dylib 0x0000000222264868 _call_dispose_helpers_excp + 72 (generic_helpers.c:34)
10 libsystem_blocks.dylib 0x0000000222264354 _Block_release + 236 (runtime.cpp:1017)
11 libdispatch.dylib 0x000000019f357584 _dispatch_client_callout + 16 (client_callout.mm:85)
12 libdispatch.dylib 0x000000019f3745a0 _dispatch_main_queue_drain.cold.5 + 812 (queue.c:8104)
13 libdispatch.dylib 0x000000019f34cd30 _dispatch_main_queue_drain + 180 (queue.c:8085)
14 libdispatch.dylib 0x000000019f34cc6c _dispatch_main_queue_callback_4CF + 44 (queue.c:8264)
15 CoreFoundation 0x000000019742ded0 0x1973c1000 + 446160
16 CoreFoundation 0x00000001973d1634 0x1973c1000 + 67124
17 CoreFoundation 0x00000001973d2d7c 0x1973c1000 + 73084
18 GraphicsServices 0x00000001e5025454 0x1e5024000 + 5204
19 UIKitCore 0x0000000199ded890 0x199cb8000 + 1267856
20 UIKitCore 0x0000000199db8cec 0x199cb8000 + 1051884
rolfbjarne commentedon Apr 22, 2025
No updates for the moment, there hasn't been any progress here.
jonathanantoine commentedon May 6, 2025
I am seeing this a lot too. Any workaround maybe ?
sleushunou commentedon May 29, 2025
I see more than 1000 crashes on my app last 90 days with this stacktrace:
Thread 0 name: tid_103 Crashed:
0 libobjc.A.dylib 0x305b34790 objc_release_x8
1 CFNetwork 0x30db70f38 -[__NSCFURLSessionConnection dealloc]
2 CFNetwork 0x30db70c90 -[__NSCFURLLocalSessionConnection dealloc]
3 libsystem_blocks.dylib 0x41fe3da1c HelperBase::disposeCapture
4 libsystem_blocks.dylib 0x41fe3d3e0 HelperBase::destroyBlock
5 libsystem_blocks.dylib 0x41fe3d864 _call_dispose_helpers_excp
6 libsystem_blocks.dylib 0x41fe3d350 _Block_release
7 libsystem_blocks.dylib 0x41fe3d8dc HelperBase::disposeCapture
8 libsystem_blocks.dylib 0x41fe3d430 HelperBase::destroyBlock
9 libsystem_blocks.dylib 0x41fe3d864 _call_dispose_helpers_excp
10 libsystem_blocks.dylib 0x41fe3d350 _Block_release
11 libdispatch.dylib 0x31af55580 _dispatch_client_callout
12 libdispatch.dylib 0x31af7259c _dispatch_main_queue_drain.cold.5
13 libdispatch.dylib 0x31af4ad2c _dispatch_main_queue_drain
14 libdispatch.dylib 0x31af4ac68 _dispatch_main_queue_callback_4CF
15 CoreFoundation 0x30b092d8c CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
16 CoreFoundation 0x30b0364f0 __CFRunLoopRun
17 CoreFoundation 0x30b037c38 CFRunLoopRunSpecific
18 GraphicsServices 0x3a5405450 GSEventRunModal
19 UIKitCore 0x310339270 -[UIApplication _run]
20 UIKitCore 0x310304a24 UIApplicationMain
21 Gambino.IOS 0x2014344ac xamarin_UIApplicationMain (bindings.m:126)
22 Gambino.IOS 0x20178fd04 do_icall (interp.c:2310)
23 Gambino.IOS 0x20178e37c do_icall_wrapper (interp.c:2350)
24 Gambino.IOS 0x201782240 mono_interp_exec_method
25 Gambino.IOS 0x20177fdac interp_runtime_invoke (interp.c:2109)
26 Gambino.IOS 0x201745538 mono_jit_runtime_invoke (mini-runtime.c:3683)
27 Gambino.IOS 0x2016e14e4 [inlined] do_runtime_invoke (object.c:2576)
28 Gambino.IOS 0x2016e14e4 mono_runtime_invoke_checked (object.c:2792)
29 Gambino.IOS 0x2016e8608 [inlined] do_exec_main_checked
30 Gambino.IOS 0x2016e8608 mono_runtime_exec_main_checked (object.c:4775)
31 Gambino.IOS 0x20174ce84 [inlined] mono_jit_exec_internal (driver.c:1369)
32 Gambino.IOS 0x20174ce84 mono_jit_exec (driver.c:1314)
33 Gambino.IOS 0x2014486f0 xamarin_main (monotouch-main.m:495)
34 Gambino.IOS 0x2017b54d8 main (main.arm64.mm:84)
35 0x1af387f08
Zalkovalsky commentedon Jul 10, 2025
I have seen this issue on the latest .NET 9 sdk (9.0.302) too, although it's quite random in timing
sleushunou commentedon Oct 13, 2025
@rolfbjarne this bug fill be fixed in Net10?
13 remaining items
rolfbjarne commentedon Sep 21, 2026
@jonathanantoine that's unfortunate 😒 but yes, please share the full thread dump.
mlancione commentedon Sep 21, 2026
@rolfbjarne @jonathanantoine An update to the workaround I shared in April: following investigation of app crash logs, we removed explicit NSUrlSessionTask.Dispose() calls from both RemoveInflightData and handler Dispose in our local implementation.
The per-request cleanup change may be relevant to the static, never-disposed HttpClient case. The current upstream implementation still calls task?.Dispose() unconditionally in RemoveInflightData, including when cancel is false:
Keeping the handler alive therefore does not prevent individual task wrappers from being explicitly disposed. #25183 retains this behavior.
Our relevant change was:
We also removed task.Dispose() from the handler’s disposal loop, retaining cancellation and session.InvalidateAndCancel().
Our concern was releasing the wrapper’s native reference while callbacks or other cleanup paths could still involve that task. This changes release timing, but we have not established that it fixes the __NSCFURLSessionConnection dealloc crash.
For the latest report, removing explicit task disposal from per-request cleanup seems worth testing independently, under the same concurrent HTTPS workload, while monitoring crash frequency and native memory usage.
filipnavara commentedon Sep 21, 2026
We are likely hitting the same issue too, but the NativeAOT stack trace is a bit spares:
I am analyzing the Sentry data to see if there are any more clues. We didn't manage to produce a successful repro yet.
filipnavara commentedon Sep 21, 2026
I think I have a repro:
NSUrlSessionHandlerRace.zip
filipnavara commentedon Sep 21, 2026
I was lucky with the first crash happening in few seconds, it seems, but the underlying cause seems to be parallel calls to
RemoveInflightData. Only the first one succeeds in removing the request frominflightRequestsunder the lock. However, both will try to cancel/dispose the task. There doesn't seem to be proper protection for theDisposebeing called from multiple threads at the same time. This could result in second attempt to release the native object.macios/src/Foundation/NSUrlSessionHandler.cs
Lines 194 to 197 in 5d3db26
Presumably this may fix it:
rolfbjarne commentedon Sep 21, 2026
Thanks for the test case! A fix is in progress (looks somewhat similar to what you suggested).
[Foundation] Avoid racing native NSUrlSessionTask cleanup in NSUrlSes…
[release/11.0.1xx-rc.2] [Foundation] Avoid racing native NSUrlSession…
jonathanantoine commentedon Oct 8, 2026
@rolfbjarne @filipnavara thanks a lot for the repro and the fix. That race explains every variant I see (main queue and NSURLSession-work queue, zero managed frames).
Is a backport of #26668 to .NET 10 servicing planned? I only see the release/11.0.1xx-rc.2 one (#26730). My app ships on net10.0-ios (Microsoft.iOS 26.5.x) and still gets this crash in production on every build, about 3-4 a day over the last two weeks, from static, never-disposed HttpClient instances. Moving to .NET 11 is not something I can do right away, so a 10.0 servicing fix would help a lot.
rolfbjarne commentedon Oct 14, 2026
@jonathanantoine
I've started the backporting process to .NET 10, but I'm not sure when it'll actually be released. The changes are somewhat risky, so we might wait a bit to see if anybody reports any regressions in .NET 11 before we backport to .NET 10.