-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Don't block specific generic types in field marshalling scenarios. #31679
Don't block specific generic types in field marshalling scenarios. #31679
Conversation
Test? |
Added |
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.
Thanks!
…ios and still block Vector types.
.NET Core 3.x shipped without this block. E.g. the following works fine in .NET Core 3.x:
Is adding the block for these a breaking change? |
Was it allowed to cross the P/Invoke boundary or just allowed in functions like |
It was allowed to cross P/Invoke boundary too. |
That's unfortunate. The intent was that it shouldn't be allowed as |
I take it based on this feedback that we want to switch this back to only explicitly blocking |
For this PR, we should make it do what it did in .NET Core 3.0. If you would like to propose breaking changes against the .NET Core 3.0 behavior, it should be separate issue / PR. |
Sounds good to me. |
Could you please add tests for the different cases we have discussed above? |
Will do! |
Could you also match this with MarshalHelpers.cs in Crossgen2? runtime/src/coreclr/src/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs Lines 337 to 355 in a716fa2
If you need to narrow down to field marshalling only, the |
… back-compat reasons.
…n't block them now.
Linux job failure is an intermittent issue tracked with AzDO. I'm going to merge this in so we can unblock Bing. |
Bing is using
Marshal.SizeOf
to calculate the size of structs that contain aNullable<T>
field. In the old system, this would unexpectedly work since we apparently allowed using generic structs as fields in interop types (but not generic classes). See the&& ELEMENT_TYPE_CLASS
at the end of the condition on line 208: https://github.com/dotnet/coreclr/blob/release/3.1/src/vm/fieldmarshaler.cpp#L208-L211Semantically, the correct function for users to call here would be
Unsafe.SizeOf<T>
, but there's a large number of users who useMarshal.SizeOf
instead ofUnsafe.SizeOf
for various reasons.Fixes #31640