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

await fulfillment(...) triggers a concurrency error in Swift 6 mode #507

Open
cthielen opened this issue Jan 30, 2025 · 1 comment
Open
Assignees
Labels

Comments

@cthielen
Copy link

cthielen commented Jan 30, 2025

The following code produces a concurrency error in Swift 6 mode:

@MainActor
func test_bla() async {
    let something = expectation(description: "bla")
    Task {
        try? await Task.sleep(for: .seconds(1.0))
        something.fulfill()
    }
    await fulfillment(of: [something])
}

(Credit Gero Herk for the sample, from https://forums.swift.org/t/swift-5-10-concurrency-and-xctest/69929/6)

The error is:

await fulfillment(of: [something], timeout: 5)
      `- warning: sending main actor-isolated value of type 'SomeXCTestCase' with later accesses to nonisolated context risks causing data races; this is an error in the Swift 6 language mode

This was temporarily fixed for the 5.10 branch using @_unsafeInheritExecutor: #479, but it is occurring now on Swift 6 OSS toolchains.

@grynspan
Copy link
Contributor

We fixed this in release/5.10 with the old @_unsafeInheritExecutor (as mentioned) but never went ahead with adopting #isolation in 6.0. We can do this for 6.1 though.

@grynspan grynspan self-assigned this Jan 30, 2025
@grynspan grynspan added the bug label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants