Skip to content

[Property Wrappers] Fix a crash in merge-modules with wrapped parameters. #37407

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
May 13, 2021

Conversation

hborla
Copy link
Member

@hborla hborla commented May 13, 2021

This is fallout from #36521 that caused a crash in merge modules when the source was compiled with -emit-module-source-info and -enable-testing.

After deserializing a property wrapper on a parameter, we check if the interface type of the parameter is valid. For property wrappers with init(projectedValue), this ends up going through PropertyWrapperBackingPropertyTypeRequest, which is called from ParamDecl::toFunctionParam. After the above PR, this request now depends on PropertyWrapperAuxiliaryVariablesRequest. The compiler ended up in infinite recursion (and eventually crashed) trying to synthesize the auxiliary variables for the wrapped parameter, because it got stuck trying to find the serialized location of the wrapped parameter. The fix is to return early from computing the backing property wrapper type in the case where the declaration came from a module file, because the auxiliary variables have already been computed and type checked anyway.

Note: I think a better way to handle this is to set the resolved type of the wrapper attribute in the constraint system (and get rid of the side cache for the backing type) so it’s always serialized with the resolved type, but doing this breaks a lot of interface printing and SourceKit tests, and I intend to cherry-pick this to release/5.5 so I'd like to keep the fix targeted for now.

Resolves: rdar://77804605

…type

if the wrapped property came from a module file.
@hborla hborla requested a review from xedin May 13, 2021 16:22
@hborla
Copy link
Member Author

hborla commented May 13, 2021

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented May 13, 2021

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented May 13, 2021

@swift-ci please smoke test macOS platform

@hborla
Copy link
Member Author

hborla commented May 13, 2021

@swift-ci please smoke test Linux platform

@hborla
Copy link
Member Author

hborla commented May 13, 2021

None of the debug source compatibility projects actually failed; looks like an infrastructure issue.

@hborla hborla merged commit c305b57 into swiftlang:main May 13, 2021
@hborla hborla deleted the wrapped-parameter-serialization branch May 13, 2021 22:48
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