You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vararray=newint[]{1,2,3,4,5};// Uses RVA field for initializationforeach(vartypeintypeof(Program).Assembly.GetTypes()){if(type.Name.Contains("PrivateImplementationDetails")){foreach(varfieldintype.GetFields(System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.NonPublic)){_=field.GetValue(null);_=field.GetValue(null);}}}
Currently, the first call is correctly handled by the slow path. Subsequent calls are handled by FieldAccessor and failing. The problems are:
RuntimeFieldHandle.GetStaticFieldAddress is returning the RVA offset, not its address. Trying to access it will cause access violation, and translated to NullReferenceException because it's typically at page 0.
The managed side of FieldAccessor tries to read the field as boxed. RVA fields are not boxed.
Test is added in #102739. I'm already working on the fix.
The text was updated successfully, but these errors were encountered:
#102739 (comment)
Currently, the first call is correctly handled by the slow path. Subsequent calls are handled by FieldAccessor and failing. The problems are:
RuntimeFieldHandle.GetStaticFieldAddress
is returning the RVA offset, not its address. Trying to access it will cause access violation, and translated toNullReferenceException
because it's typically at page 0.FieldAccessor
tries to read the field as boxed. RVA fields are not boxed.Test is added in #102739. I'm already working on the fix.
The text was updated successfully, but these errors were encountered: