Skip to content
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

Fix field accessor for RVA field #103705

Merged
merged 3 commits into from
Jun 24, 2024
Merged

Conversation

huoyaoyuan
Copy link
Member

Fixes #103207

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 19, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

{
byte[] valueArray = new byte[] { 1, 2, 3, 4, 5 };

// Roslyn uses SHA256 of raw data as data field name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting; this is likely why the original RVA tests added with the fast field feature didn't fail.

Copy link
Member

@steveharter steveharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@steveharter steveharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a test failure on macOS-12.7.2. Does Mono do things differently?

[FAIL] System.Reflection.Tests.FieldInfoTests.GetValueFromRvaField
System.NotSupportedException : This object cannot be invoked because no code was generated for it: '<PrivateImplementationDetails>.74F81FE167D99B4CB41D6D0CCDA82278CAEE9F3E2F25D5E5A3936FF3DCEC60D0'.
   at System.Reflection.Runtime.FieldInfos.RuntimeFieldInfo.get_FieldAccessor() + 0xe8
   at System.Reflection.Runtime.FieldInfos.RuntimeFieldInfo.GetValue(Object) + 0x14
   at System.Reflection.Tests.FieldInfoTests.GetValueFromRvaField() + 0x120
   at System.Reflection!<BaseAddress>+0xb29b40
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x10c

@huoyaoyuan
Copy link
Member Author

It's NativeAOT. Seems that NativeAOT doesn't support reflection on RVA field. Let's see if it can easily be added or just disable the test.

@dotnet/ilc-contrib

@jkotas
Copy link
Member

jkotas commented Jun 20, 2024

Seems that NativeAOT doesn't support reflection on RVA field. Let's see if it can easily be added or just disable the test.

I do not think that it is something we want enable. Could you please disable the test for NAOT?

@MichalStrehovsky
Copy link
Member

It's NativeAOT. Seems that NativeAOT doesn't support reflection on RVA field. Let's see if it can easily be added or just disable the test.

Agreed with Jan. This would only be useful for two things: C++/CLI support and support for (non-intrinsic) RuntimeHelpers.InitializeArray. Native AOT has both listed as unplanned in #69919.

The whole reflection with RVA static field business would ideally be just blocked everywhere, it has always been buggy - calling SetValue on RVA statics on .NET Framework crashes the runtime badly, and accessing RVA statics in the TLS range doesn't work as expected (accessing fields marked thread_local in C++/CLI will read the template default value instead of the current value of the threadstatic).

@huoyaoyuan
Copy link
Member Author

The failures look unrelated now.

@jkotas jkotas merged commit b79c57e into dotnet:main Jun 24, 2024
143 of 148 checks passed
@huoyaoyuan huoyaoyuan deleted the field-accessor-rva branch June 25, 2024 01:27
@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Reflection community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FieldAccessor can't read RVA field correctly
5 participants