Skip to content

[5.9] Fix MoveOnlyAddressChecker to handle value deinits #66778

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 2 commits into from
Jun 21, 2023

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jun 20, 2023

Fixes rdar://110232973 ([move-only] Checker should distinguish in between field of single field struct vs parent field itself (was: mutation of field in noncopyable struct should not trigger deinit))

(cherry picked from commit a8c45c5)

--- CCC ---

  • Explanation: Track liveness of self so we don't accidentally think that such types can be memberwise reinitialized.

  • Scope of Issue: Miscompilation occurs for a NonCopyable struct with a deinit. The deinitializer incorrectly runs when the programmer reassigns the struct fields.

  • Risk: This change only affects the MoveOnlyAddressChecker, which was already miscompiling cases that weren't explicitly tested.

  • PR to main: Fix MoveOnlyAddressChecker to handle value deinits. #66691

  • Reviewed By: Michael Gottesman

  • Resolves: rdar://110232973 ([move-only] Checker should distinguish in between field of single field struct vs parent field itself (was: mutation of field in noncopyable struct should not trigger deinit))

Track liveness of self so we don't accidentally think that such types
can be memberwise reinitialized.

Fixes rdar://110232973 ([move-only] Checker should distinguish in
between field of single field struct vs parent field itself (was:
mutation of field in noncopyable struct should not trigger deinit))

(cherry picked from commit a8c45c5)
@atrick atrick requested review from gottesmm and tbkka June 20, 2023 19:40
@atrick atrick requested a review from a team as a code owner June 20, 2023 19:40
@atrick
Copy link
Contributor Author

atrick commented Jun 20, 2023

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jun 20, 2023

Note that this needed to be updated for 5.9:

73:14: error: no member named 'isValueTypeWithDeinit' in 'swift::SILType'
    if (type.isValueTypeWithDeinit()) {
        ~~~~ ^

Needs to be

if (auto *nominal = getNominalOrBoundGenericNominal()) {
    if (nominal->getValueTypeDestructor() != nullptr) {

@atrick
Copy link
Contributor Author

atrick commented Jun 20, 2023

@swift-ci test

because the SILType method has not been merged to 5.9.
@atrick atrick force-pushed the 5.9-fix-field-liveness branch from b9f9c74 to 6826ff1 Compare June 20, 2023 23:09
@atrick
Copy link
Contributor Author

atrick commented Jun 20, 2023

@swift-ci test

@atrick atrick merged commit 524a8f5 into swiftlang:release/5.9 Jun 21, 2023
@atrick atrick deleted the 5.9-fix-field-liveness branch June 21, 2023 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants