Skip to content

[SILGen] Fix a miscompile when emitting the application of a wrapped parameter #37301

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

Conversation

hborla
Copy link
Member

@hborla hborla commented May 7, 2021

Don't pass down the SGFContext when emitting the r-value of the argument to the property wrapper generator function. This silly mistake caused a miscompile when the argument to the property wrapper initializer contains address-only types (e.g. resilient types). The SGFContext passed to visitAppliedPropertyWrapperExpr had the emit-into buffer for the result of emitApplyOfPropertyWrapperBackingInitializer. If the argument to the backing initializer was an address-only type, it was incorrectly initialized in place. Because this wasn't the RValue returned by visitAppliedPropertyWrapperExpr, the caller would overwrite the buffer with the correct result, which meant that the r-value of the argument ended up not being emitted.

Without this change, the added test case fails in the SIL verifier with:

SIL verification failed: Found mutating or consuming use of an in_guaranteed parameter?!: !ImmutableAddressUseVerifier().isMutatingOrConsuming(fArg)

Thanks to @slavapestov for helping me understand what was going wrong here.

Resolves: rdar://77572130

@hborla hborla requested a review from slavapestov May 7, 2021 02:21
@hborla
Copy link
Member Author

hborla commented May 7, 2021

@swift-ci please smoke test

… wrapped

or projected value in RValueEmitter::visitAppliedPropertyWrapperExpr
@hborla hborla force-pushed the wrapped-parameter-miscompile branch from 03230ef to 0999dea Compare May 7, 2021 15:52
@hborla
Copy link
Member Author

hborla commented May 7, 2021

@swift-ci please smoke test

@hborla hborla merged commit 833a453 into swiftlang:main May 7, 2021
@hborla hborla deleted the wrapped-parameter-miscompile branch May 7, 2021 19:44
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