Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: withTaskGroup crashes immediately for iOSAppOnMac #75771

Open
KaiOelfke opened this issue Aug 8, 2024 · 12 comments
Open

Regression: withTaskGroup crashes immediately for iOSAppOnMac #75771

KaiOelfke opened this issue Aug 8, 2024 · 12 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself concurrency Feature: umbrella label for concurrency language features crash Bug: A crash, i.e., an abnormal termination of software TaskGroup Area → standard library → Concurrency: The `TaskGroup` type

Comments

@KaiOelfke
Copy link

Description

With Xcode 16.0 beta 5 and Swift 6.0 (6.0.0.7.6) the code sample below crashes, when running as iOS app on mac (iOS apps can run on macOS devices with Apple Silicon). E.g. this applies to destinations where https://developer.apple.com/documentation/foundation/processinfo/3608556-isiosapponmac ProcessInfo.processInfo.isiOSAppOnMac is true.

Reproduction

Create a new iOS SwiftUI project with the default template and extend the template ContentView with a task modifier and a task group or just use withTaskGroup anywhere else.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
        }
        .padding()
        .task {
            await withTaskGroup(of: Void.self) { _ in } // Thread 1: EXC_BAD_ACCESS (code=1, address=0x4)
        }
    }
}

Stack dump

Thread 1: EXC_BAD_ACCESS (code=1, address=0x4)

    0x102e3d1cc <+204>: str    x10, [x22]
    0x102e3d1d0 <+208>: adrp   x10, 0
    0x102e3d1d4 <+212>: add    x10, x10, #0x260          ; (1) await resume partial function for back deployment thunk for Swift.withTaskGroup<ChildTaskResult, GroupResult where ChildTaskResult: Swift.Sendable>(of: ChildTaskResult.Type, returning: GroupResult.Type, isolation: isolated Swift.Optional<Swift.Actor>, body: (inout Swift.TaskGroup<ChildTaskResult>) async -> GroupResult) async -> GroupResult at <compiler-generated>
    0x102e3d1d8 <+216>: str    x10, [x22, #0x8]
    0x102e3d1dc <+220>: str    x9, [x29, #0x10]
    0x102e3d1e0 <+224>: ldp    x29, x30, [sp, #0x70]
    0x102e3d1e4 <+228>: and    x29, x29, #0xefffffffffffffff
    0x102e3d1e8 <+232>: add    sp, sp, #0x80
    0x102e3d1ec <+236>: br     x8
    0x102e3d1f0 <+240>: adrp   x8, 7
    0x102e3d1f4 <+244>: ldr    x8, [x8, #0x288]
->  0x102e3d1f8 <+248>: ldr    w8, [x8, #0x4]
    0x102e3d1fc <+252>: mov    x0, x8
    0x102e3d200 <+256>: bl     0x102e40670               ; symbol stub for: swift_task_alloc
    0x102e3d204 <+260>: ldur   x10, [x29, #-0x20]
    0x102e3d208 <+264>: ldur   x9, [x29, #-0x18]
    0x102e3d20c <+268>: ldur   x8, [x29, #-0x28]
    0x102e3d210 <+272>: ldr    x1, [sp, #0x38]
    0x102e3d214 <+276>: ldr    x2, [sp, #0x30]
    0x102e3d218 <+280>: ldr    x3, [sp, #0x28]
    0x102e3d21c <+284>: ldr    x4, [sp, #0x20]

Expected behavior

withTaskGroup should not crash and behave as in previous Xcode / Swift versions.

Environment

Xcode 16.0 beta 5 (16A5221g)
Swift 6.0 (6.0.0.7.6)
iOSAppOnMac

Additional information

No response

@KaiOelfke KaiOelfke added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Aug 8, 2024
@tcwalther
Copy link

tcwalther commented Aug 8, 2024

I have the same problem on a physical iOS 18.0 beta 4 device where the code is crashing on a withTaskGroup call. However, my project still runs on Swift 5, so I believe this is an error in the libraries, not the Swift language.

It runs fine on an iOS 17.5 simulator (I have another regression on the iOS 18 simulator and thus cannot test my project there yet). It worked fine on previous Xcode 16 betas before Xcode 16.0 beta 5.

@WillBishop
Copy link

I'm getting crashes using withTaskGroup on-device (but not in Simulator) running Xcode 16 Beta 5, on an iPad

@xedin xedin added concurrency Feature: umbrella label for concurrency language features compiler The Swift compiler itself TaskGroup Area → standard library → Concurrency: The `TaskGroup` type and removed triage needed This issue needs more specific labels labels Aug 12, 2024
@Benny-Nottonson
Copy link

Can confirm, happening on-device and on iPhone 15, both on iOS 18 Dev Beta, also seems to affect withThrowingTaskGroup

@KaiOelfke
Copy link
Author

Update for Xcode 16 beta 6 for the sample above:

  • Debug configuration always crashing
  • Release configuration:
    • first build and run after clean crashes
    • incremental build and run after the step above run successfully
  • Archiving app, exporting ipa and running as iOS app on mac runs sucessfully

@msdrigg
Copy link

msdrigg commented Aug 25, 2024

I am seeing this on iPhone iOS 18 and Xcode 16 beta 6 with withTaskGroup and withDiscardingTaskGroup configurations. All my task groups are crashing, without fail in my application (which is open source here https://github.com/msdrigg/roam).

This is not iOSAppOnMac, it's running a SwiftUI application on a native iOS device (not simulator).

Additionally I don't see this error when I run the same application directly on macOS (it's cross-platform through swiftui)

@hborla
Copy link
Member

hborla commented Aug 26, 2024

I have the same problem on a physical iOS 18.0 beta 4

It worked fine on previous Xcode 16 betas before Xcode 16.0 beta 5.

There is an ABI mismatch between iOS/macOS Beta 4 and Xcode 16 Beta 5 for the withTaskGroup APIs. The issue should be resolved if you match the betas, i.e. build with Xcode 16 Beta 5+ and run on iOS 18 Beta 5+. This ABI mismatch does not apply when back deploying to a previous macOS or iOS release.

@KaiOelfke
Copy link
Author

This ABI mismatch does not apply when back deploying to a previous macOS or iOS release.

Isn't compiling with Xcode 16 beta 6 to run an iOS app on macOS Sonoma 14.6.1 (23G93) back deploying to a previous iOS(AppOnMac) release?

Because this crashes as mentioned in my last comment. So we currently can't use Xcode 16 beta for the development of iOSAppOnMac apps on macOS Sonoma.

@KaiOelfke
Copy link
Author

After distributing apps built with Xcode 16 RC on the App Store I'm seeing now a lot of crashes for withTaskGroup or withCheckedContinuation. It appears to be devices, which are still on iOS 18 betas instead of the RC. I assume there's an ABI mismatch as well.

@witekbobrowski
Copy link

witekbobrowski commented Sep 19, 2024

After distributing apps built with Xcode 16 RC on the App Store I'm seeing now a lot of crashes for withTaskGroup or withCheckedContinuation. It appears to be devices, which are still on iOS 18 betas instead of the RC. I assume there's an ABI mismatch as well.

We are seeing the exact same issue as well in our project. We have managed to fix some crashes from withCheckedContinuation calls by rewriting/simplifying the concurrency stack in these places but we are out of ideas for workarounds to the withTaskGroup crash.

FB15175069

@dfed
Copy link

dfed commented Sep 20, 2024

Anyone know if macOS 14.7 has the required fix? Tempted to "fix" this by bumping our min deployment target...

@ivanpondal
Copy link

Hello, I'm having the same issue. Any workarounds?

@lorrainNicolas
Copy link

Hello we are having also the same issue with iios18 and withTaskGroup any fix ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself concurrency Feature: umbrella label for concurrency language features crash Bug: A crash, i.e., an abnormal termination of software TaskGroup Area → standard library → Concurrency: The `TaskGroup` type
Projects
None yet
Development

No branches or pull requests