We are seeing a swift concurrency related crash in iOS 18 and iOS 18.1 that has no direct link to any part of my code base in the stack trace. We are not able to reproduce locally but see it in the Organizer. The crash seems to come from withTaskCancellationHandler in Concurrency.swift
Incident Identifier: C5331198-3922-471F-8E39-57186BBB962B
Distributor ID: com.apple.AppStore
Hardware Model: iPhone16,2
Process: MyApp [866]
Path: /private/var/containers/Bundle/Application/B320C8CF-5711-4F14-92C4-0693420DDE07/MyApp.app/MyApp
Identifier: com.MyApp.release
Version: 10.0.1 (1)
AppStoreTools: 16A242b
AppVariant: 1:iPhone16,2:18
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.MyApp.release [989]
Date/Time: 2024-09-21 06:30:38.3210 -0500
Launch Time: 2024-09-21 06:18:03.0691 -0500
OS Version: iPhone OS 18.1 (22B5007p)
Release Type: Beta
Baseband Version: 2.15.01
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000004
Exception Codes: 0x0000000000000001, 0x0000000000000004
VM Region Info: 0x4 is not in any region. Bytes before following region: 4340908028
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 102bd0000-102be0000 [ 64K] r-x/r-x SM=COW /var/containers/Bundle/Application/B320C8CF-5711-4F14-92C4-0693420DDE07/MyApp.app/MyApp
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [866]
Triggered by Thread: 3
Thread 3 Crashed:
0 MyApp 0x0000000103b00b8c withTaskCancellationHandler<A>(operation:onCancel:isolation:) + 108 (/<compiler-generated>:0)
1 MyApp 0x0000000103b0284d closure #1 in DataRequest.dataTask<A>(automaticallyCancelling:forResponse:) + 1 (Concurrency.swift:352)
2 MyApp 0x0000000102f66011 partial apply for closure #1 in closure #1 in variable initialization expression of static FireAndForgetKey.liveValue + 1
3 MyApp 0x0000000102f80841 closure #1 in DataTask.response.getter + 1
4 MyApp 0x0000000102f66011 partial apply for closure #1 in closure #1 in variable initialization expression of static FireAndForgetKey.liveValue + 1
5 libswift_Concurrency.dylib 0x000000019164e689 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:471)
Hmmm... Looked at alamofire and looks like someone has reported a similar issue. https://github.com/Alamofire/Alamofire/issues/3896
They seem to be saying that it's a bug in the swift runtime however: https://github.com/swiftlang/swift/issues/75952
Hopefully a fix is coming very soon from Apple, since it doesn't look like a workaround is available.