Skip to content

Short-circuit GlobalActorAttributeRequest attempting to get the Source Location of a serialized decl. #38034

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

artemcm
Copy link
Contributor

@artemcm artemcm commented Jun 22, 2021

When querying the attr from a serialized decl, dependning on deserialization order, getting its source-location may launch into arbitrary type-checking when querying interface types of such decls. Which, in turn, may do things like query (to print) USRs. This ends up being prone to request evaluator cycles.

Because this only applies to serialized decls, we can be confident that they already fell through this checking as primaries, so, for now, to avoid cycles, we simply ignore the source location on serialized decls only.

Long-term, we are planning to remove the merge-modules jobs, which will help with not having to deal with this scenario.
Alternatively, we would need to ensure that at decl deserialization time we cache the GlobalActorAttributeRequest when we see this attribute, but this would require further surgery to either serialization format or the GlobalActorAttr model, because such caching requires access to the DeclID of the global actor being referenced, which is not currently easily accessible.

Resolves rdar://79563942

…rce Location of a serialized decl.

When querying the attr from  a serialized decl, dependning on deserialization order, getting its source-location may launch into arbitrary type-checking when querying interface types of such decls. Which, in turn, may do things like query (to print) USRs. This ends up being prone to request evaluator cycles.

Because this only applies to serialized decls, we can be confident that they already fell through this checking as primaries, so, for now, to avoid cycles, we simply ignore the source location on serialized decls only.

Long-term, we are planning to remove the `merge-modules` jobs, which will help with not having to deal with this scenario.
Alternatively, we would need to ensure that at decl deserialization time we cache the `GlobalActorAttributeRequest` when we see this attribute, but this would require further surgery to either serialization format or the `GlobalActorAttr` model, because such caching requires access to the `DeclID` of the global actor being referenced, which is not currently easily accessible.

Resolves rdar://79563942
@artemcm artemcm requested review from DougGregor and CodaFi June 22, 2021 20:46
@artemcm
Copy link
Contributor Author

artemcm commented Jun 22, 2021

@swift-ci please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

This is shockingly subtle, but as a short-term fix it LGTM.

@artemcm
Copy link
Contributor Author

artemcm commented Jun 22, 2021

@swift-ci please test Windows platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6dc6adb

@artemcm
Copy link
Contributor Author

artemcm commented Jun 23, 2021

The failure is an unrelated error that is being investigated.

@artemcm
Copy link
Contributor Author

artemcm commented Jun 23, 2021

@swift-ci please test macOS platform

@artemcm artemcm merged commit bffba72 into swiftlang:main Jun 23, 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.

4 participants