Skip to content

[Serialization] Expect missing custom attributes in deserializeDeclCommon #62328

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
merged 1 commit into from
Dec 1, 2022

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Nov 30, 2022

Attr can be null here if it was a custom attribute from an implementation-only dependency.

rdar://102525437

@xymus xymus requested a review from gottesmm November 30, 2022 22:48
@xymus
Copy link
Contributor Author

xymus commented Nov 30, 2022

@swift-ci Please smoke test

@xymus xymus requested a review from bnbarham November 30, 2022 23:47
@@ -5306,7 +5306,7 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {

// Do a quick check to see if this attribute is a move only attribute. If
// so, emit a nice error if we don't have experimental move only enabled.
if (Attr->getKind() == DeclAttrKind::DAK_MoveOnly &&
if (Attr && Attr->getKind() == DeclAttrKind::DAK_MoveOnly &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also move this into AddAttribute where it's not null any more, or move into the if below (though I haven't looked where skipAttr is set, so maybe that's not possible?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like skipAttr is set to true whenever Attr remains null. We could likely remove skipAttr, or just exit when we can't set the attribute.

@bnbarham
Copy link
Contributor

FWIW this is a little confusing to me, I'd expect basically any test that deserializes custom attributes to be crashing if this was the case 🤔. Does it only happen in very specific circumstances?

@xymus
Copy link
Contributor Author

xymus commented Dec 1, 2022

It would only crash when a custom attribute depends on implementation-only imported details, in such a case we ignore the attribute. In this case the attribute was applied to a private var, so we shouldn't even try to deserialize it.

Attr can be null here if it was a custom attribute from an
implementation-only dependency.

rdar://102525437
@xymus xymus changed the title [Serialization] Expect unknown/custom attributes in deserializeDeclCommon [Serialization] Expect missing custom attributes in deserializeDeclCommon Dec 1, 2022
@xymus
Copy link
Contributor Author

xymus commented Dec 1, 2022

Added back a test case that would have triggered this crash, using an implementation-only imported property wrapper on a private field.

@swift-ci Please smoke test

@xymus xymus merged commit 079369f into swiftlang:main Dec 1, 2022
@xymus xymus deleted the fix-102525437 branch December 1, 2022 16:52
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