Skip to content

[Concurrency] Fix swift_taskGroup_initializeWithFlags availability #67669

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

Merged

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
Radar: rdar://112469076

@ktoso ktoso requested review from etcwilde, tomerd, mikeash and rjmccall and removed request for xedin, slavapestov, hborla and tshortli August 2, 2023 03:05
@ktoso
Copy link
Contributor Author

ktoso commented Aug 2, 2023

@swift-ci please smoke test

@ktoso ktoso added the concurrency Feature: umbrella label for concurrency language features label Aug 2, 2023
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ktoso ktoso merged commit d26bdd3 into swiftlang:main Aug 2, 2023
@ktoso ktoso deleted the wip-fix-availability-group-init-runtime-func branch August 2, 2023 05:37
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants