-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Don't consider types with empty base classes blittable. They have a different managed and native size. #46653
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
…ifferent managed and native size.
|
One possible hiccup with this fix is that this blocks creating a Pinned GC Handle to types that match this pattern (since that only allows blittable types). |
| } | ||
|
|
||
| [Fact] | ||
| public void SizeOf_TypeWithEmptyBase_ReturnsExpected() |
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.
Just to confirm, this test would have failed prior to the above change - correct?
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.
Yes, it would have failed since the SizeOf call would return 8.
|
Hello @jkoritzinsky! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
|
Crossgen2 also has a definition of
I'm not sure if a mismatch here can result in an issue with R2R, but the added test would definitely not uncover a crossgen2 issue because crossgen2 is not involved in Cc @dotnet/crossgen-contrib |
|
/backport to release/5.0 |
|
Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/469820851 |
|
Filed #46738 for crossgen2. |
With the refactoring of native type layout information loading to be lazy, we made an assumption that if a type is blittable, the managed size, alignment, and field layout are all equal to the native size, alignment, and field layout. However, our calculation of blittability didn't account for the case of a type with blittable fields having an empty base class. As a result, we were considering these types blittable when they weren't.
Fixes #46643