Skip to content

6.0: [MoveOnlyAddressChecker] Fix empty deiniting struct representation. #73178

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

Conversation

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented Apr 22, 2024

Explanation: Fix MoveOnlyAddressChecker miscompile caused by not representing empty struct with deinit.

The checker represents each type as a bitfield. An empty struct without a deinit gets a single bit--that bit corresponds to the whole struct. That allows the checker to track uses of the whole struct as a use of some bit.

Previously, the checker only represented an empty struct with a deinit as a single bit too. The single bit in this case corresponds to the deinit. When the deinit is dropped via discard, there is still an empty struct whose lifetime needs representation in bits--it should have the same number of bits as an empty struct without a deinit--i.e. two.

Here, the problem is fixed by giving an empty struct with a deinit two bits.
Scope: Affects noncopyable code.
Issue: rdar://126863003
Original PR: #73174
Risk: Low.
Testing: Added and updated unit tests.
Reviewer: @kavon

@nate-chandler nate-chandler requested a review from a team as a code owner April 22, 2024 17:01
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@Sadewoabdi
Copy link

Sadewoabdi commented Apr 22, 2024 via email

An empty struct without a deinit gets a single bit which is used to
track the struct's liveness.  Previously, an empty struct with a deinit
also only got a single bit.  Consequently, when discarding the struct
(i.e. dropping the deinit), there was no bit left to represent the
struct.  This resulted in a failure to track liveness for the value.

rdar://126863003
@nate-chandler nate-chandler force-pushed the cherrypick/release/6.0/rdar126863003 branch from 65ab9eb to 74a2c76 Compare April 22, 2024 18:04
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler enabled auto-merge April 22, 2024 18:05
@nate-chandler nate-chandler merged commit 6822ad9 into swiftlang:release/6.0 Apr 22, 2024
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar126863003 branch April 22, 2024 23:43
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