Skip to content

🍒[5.9][Concurrency] Fix init task group with flags availability #67670

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

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Aug 2, 2023

Description: The new runtime function swift_taskGroup_initializeWithFlags introduced to support discarding task group initialization has wrong availability. It must have availability equal to when it was introduced, but had the "general" concurrency one. Its availability must be 5.9. If we don't do this, then code like this:

if #available(iOS 17.0, *) {
    await withDiscardingTaskGroup {
        $0.addTask {
            try? await Task.sleep(for: .seconds(1))
        }
    }
}

can crash when compiled against iOS 16 target, since it'd attempt to strong refer to the symbol, but it's missing, yielding a Symbol not found: _swift_taskGroup_initializeWithFlags

Risk: Low, the method we're changing availability of cannot be called from user code, and is only called in IRGen generated code inside a method that is properly availability annotated already.
Reward: High, without the fix adopting discarding task groups is limited in apps which also need to support older versions of iOS which do not have this API, as the "usual" if #available guarding does not prevent the crash.
Review by: @rjmccall @mikeash
Testing: CI testing
Original PR: #67669
Radar: rdar://112469076

@ktoso ktoso requested a review from a team as a code owner August 2, 2023 04:00
@ktoso ktoso requested review from rjmccall and hborla August 2, 2023 04:00
@ktoso ktoso changed the title [Concurrency] Fix init task group with flags availability 🍒[5.9][Concurrency] Fix init task group with flags availability Aug 2, 2023
@ktoso ktoso added concurrency Feature: umbrella label for concurrency language features 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels Aug 2, 2023
@ktoso
Copy link
Contributor Author

ktoso commented Aug 2, 2023

@swift-ci please test

1 similar comment
@ktoso
Copy link
Contributor Author

ktoso commented Aug 2, 2023

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Aug 2, 2023

Ted approved, merging.

@ktoso ktoso merged commit 4ac22d8 into swiftlang:release/5.9 Aug 2, 2023
@ktoso ktoso deleted the pick-fix-availability-group-init-runtime-func branch August 3, 2023 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency Feature: umbrella label for concurrency language features 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants