Runtime crash on iOS 17 from nonisolated(nonsending) type metadata when built with Xcode 26.3 / Swift 6.2

Hi all,

I'd like to surface a crash we hit after upgrading our app's build toolchain to Xcode 26.3 (Swift 6.2). Sharing in case others run into it, and to ask whether this is an expected back-deployment limitation or something the runtime should handle more gracefully or there is something I am missing ?

Environment

  • Xcode: 26.3 (Swift 6.2)
  • Deployment target: iOS 16
  • Crashing OS: iOS 17.x (simulator and device, all variants)
  • Working OS: iOS 18+
  • Affected upcoming feature: NonisolatedNonsendingByDefault (SE-0461)

Symptom

The app launches fine but crashes the moment SwiftUI tries to render certain screens whose view models contain async APIs. The crashing thread is always a com.apple.root.utility-qos queue, and the top of the stack is a null deref:

0  0x00000000                                       (memory read failed for 0x0)
1  type metadata accessor for nonisolated(nonsending) ()   MyApp.debug.dylib
2  swift_getTypeByMangledNodeImpl                          libswiftCore.dylib
3  swift_getTypeByMangledName                              libswiftCore.dylib
4  AG::swift::metadata::mangled_type_name_ref              AttributeGraph
5  AG::swift::metadata_visitor::visit_field                AttributeGraph
6  AG::swift::metadata::visit                              AttributeGraph
7  AG::LayoutDescriptor::make_layout                       AttributeGraph
8  AG::(anonymous namespace)::TypeDescriptorCache::fetch   AttributeGraph

Diagnosis

The compiler emits a type-metadata accessor whose mangled name references nonisolated(nonsending). The iOS 17 Swift runtime has no demangling support for that production, so swift_getTypeByMangledName returns null. AttributeGraph then walks the null metadata while building the view's layout descriptor and crashes.

The trigger is the NonisolatedNonsendingByDefault upcoming feature being enabled — either explicitly via .enableUpcomingFeature("NonisolatedNonsendingByDefault") in a SwiftPM target, or implicitly via the Xcode build setting SWIFT_APPROACHABLE_CONCURRENCY = YES, which turns it on as part of the bundle.

Critically, the metadata is emitted even for code that doesn't write nonisolated(nonsending) explicitly — any nonisolated async function in the module, plus inferred types in SwiftUI view bodies, ends up referencing the new mangled production. So a single SwiftPM dependency compiled with the feature on poisons every screen whose view tree includes its types.

Fix

Disable the feature for any module that gets linked into a binary running on iOS 17:

// Package.swift
swiftSettings: [
    // .enableUpcomingFeature("NonisolatedNonsendingByDefault"),  // ← remove
]
// Xcode build settings
SWIFT_APPROACHABLE_CONCURRENCY = NO
SWIFT_UPCOMING_FEATURE_NONISOLATED_NONSENDING_BY_DEFAULT = NO

Questions

  1. Is this the intended back-deployment story for NonisolatedNonsendingByDefault, i.e. it requires the iOS 18 Swift runtime and developers must gate it on deployment target? If so, it would be very helpful to surface this in the feature's release notes — currently nothing in the Xcode "Approachable Concurrency" UI hints that flipping it on will brick the app on iOS 17.
  2. Is there a Swift runtime back-deployment shim planned that would let the feature target older OSes?
  3. Or there is something I am missing I should do when adapting swift 6

Curious whether others have hit this. I could appreciate if anyone can help.

Thanks!

I ran into something similar, and I think it’s fixed in Xcode 26.4 or 26.4.1.

1 Like

Unclear. 26.4.1 states:

  • Fixed stack-allocation bugs in async functions that caused “freed pointer was not the last allocation” crashes, particularly in swift_asyncLet_finish. These long-standing issues became more frequent in Swift 6.2 and 6.3 due to optimizer improvements. (173974857)

This was mainly seen in async let usage, but retesting would be a good idea anyway, as something may have changed in Swift 6.3 generally (Xcode 26.4+).

2 Likes

so it is fixed in 26.4.1 ?

I think it is fixed in Xcode 26.4 (or rather Swift 6.3): [6.3][irgen] Fix crash when getting nonisolated(nonsending) function metadata on older runtimes by gottesmm ¡ Pull Request #86852 ¡ swiftlang/swift ¡ GitHub

2 Likes

the problem even this build have issues, there is a pieace of code we have in the code base that have nested Dispatch now they don’t compile. (I know it doesn’t make sense to have such thing :sweat_smile: but it’s legacy code)

The only workaround I know of (when using Xcode 26.0 to 26.3) is to mark those closures as @concurrent or @MainActor or something. The issue I found was that it’s difficult to find those closures in the source code.

1 Like

Thanks for sharing