Skip to content

Cherry-Pick: [Concurrency] Don't propagate global actor-ness to deinit #36976

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

etcwilde
Copy link
Member

@etcwilde etcwilde commented Apr 20, 2021

We can't make destructors run on a global-actor. This patch disables propagating global-actorness to the destructor, blocking accessing to other functions and properties that are not on the local object instance.
Since the deinit is the only place with access to the instance of the object, so we can still safely access global-actor stored properties from the deinit.

Original PR: #36972

Fixes: rdar://76769567

Destructors can't be run on the main actor since they may be called from
a asynchronous context. Because we are the only ones with a handle to
the class, we can touch Main-Actor protected properties from anywhere
safely. We can't touch static properties though since those will still
be alive and accessible from outside of just this dying instance.
Updated the tests for non-global-actor protected deinit.
We can't access main-actor synchronous functions, main-actor static
properties, but can access non-static main-actor stored properties in
the deinit.
@etcwilde etcwilde requested a review from DougGregor April 20, 2021 20:07
@etcwilde
Copy link
Member Author

@swift-ci please smoke test

@etcwilde
Copy link
Member Author

@swift-ci please test

@etcwilde
Copy link
Member Author

Failure looks like it's related to swiftlang/llvm-project#2856 not having landed in the 5.5 branch.

@etcwilde etcwilde merged commit 0c6b80e into swiftlang:release/5.5 Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants