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
Accidentally i've discovered the ability to box a ref struct by using reflection.
The scenario is the invocation via reflection of a method that has, say, an in ref struct parameter. Upon the exit of the call the parameter array passed to MethodInfo.Invoke will contain a boxed ref struct.
Probably something we should address, as boxing ref structs could destabilize the runtime. It's possible that the only reason this worked rather than resulting in an internal VM error is that the ref struct defined in the repro doesn't contain any reference-type fields.
Thanks, I've edited the post to include some fields in the struct. Even with fields it works. Yes i was thinking that this should not be allowed by the runtime as it can lead to passed stack frame reads.
Activity
Dotnet-GitSync-Bot commentedon Jul 3, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
GrabYourPitchforks commentedon Jul 3, 2020
Probably something we should address, as boxing ref structs could destabilize the runtime. It's possible that the only reason this worked rather than resulting in an internal VM error is that the ref struct defined in the repro doesn't contain any reference-type fields.
MaximGurschi commentedon Jul 3, 2020
Thanks, I've edited the post to include some fields in the struct. Even with fields it works. Yes i was thinking that this should not be allowed by the runtime as it can lead to passed stack frame reads.