-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[cxx-interop] Fix over-releasing reference members of trival C++ types #84321
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
[cxx-interop] Fix over-releasing reference members of trival C++ types #84321
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
We're not modeling these types as POD in any way in the Swift compiler, right? You're saying "POD" because C++ says they're POD, but we're modeling them as non-trivial types? |
1823a1e
to
75ec1fd
Compare
Indeed, I updated the PR title and the comments of the code to not confuse POD types in C++ with trivial types in Swift. |
75ec1fd
to
965f15f
Compare
b467982
to
502646a
Compare
Large trivial types were copied via memcpy instead of doing a field-wise copy. This is incorrect for types with reference fields where we also need to bump the corresponding refcounts. rdar://160315343
502646a
to
e4e5423
Compare
@swift-ci please test |
… types Explanation: Large trivial types were copied via memcpy instead of doing a field-wise copy. This is incorrect for types with reference fields where we also need to bump the corresponding refcounts. This PR makes sure that trival C++ types with reference members are not trivial in Swift. Issues: rdar://160315343 Original PRs: swiftlang#84321 Risk: There is a low chance of breaking source compatibility as some types that used to be BitwiseCopyable are no longer considered as such. However, code relying on that probably has latent memory safety bugs. Testing: Added a compiler test. Reviewers: @egorzhdan, @j-hui
… types Explanation: Large trivial types were copied via memcpy instead of doing a field-wise copy. This is incorrect for types with reference fields where we also need to bump the corresponding refcounts. This PR makes sure that trival C++ types with reference members are not trivial in Swift. Issues: rdar://160315343 Original PRs: swiftlang#84321 Risk: There is a low chance of breaking source compatibility as some types that used to be BitwiseCopyable are no longer considered as such. However, code relying on that probably has latent memory safety bugs. Testing: Added a compiler test. Reviewers: @egorzhdan, @j-hui
Large trivial types were copied via memcpy instead of doing a field-wise copy. This is incorrect for types with reference fields where we also need to bump the corresponding refcounts.
rdar://160315343