File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -3743,8 +3743,18 @@ uint32_t CEEInfo::getClassAttribsInternal (CORINFO_CLASS_HANDLE clsHnd)
3743
3743
if (pMT->IsByRefLike ())
3744
3744
ret |= CORINFO_FLG_BYREF_LIKE;
3745
3745
3746
- if (pClass->IsUnsafeValueClass ())
3746
+ // In Reverse P/Invoke stubs, we are generating the code
3747
+ // and we are not generating the code patterns that the GS checks
3748
+ // are meant to catch.
3749
+ // As a result, we can skip setting this flag.
3750
+ // We do this as the GS checks (emitted when this flag is set)
3751
+ // can break C++/CLI's copy-constructor semantics by missing copies.
3752
+ if (pClass->IsUnsafeValueClass ()
3753
+ && !(m_pMethodBeingCompiled->IsILStub ()
3754
+ && dac_cast<PTR_DynamicMethodDesc>(m_pMethodBeingCompiled)->GetILStubType () == DynamicMethodDesc::StubNativeToCLRInterop))
3755
+ {
3747
3756
ret |= CORINFO_FLG_UNSAFE_VALUECLASS;
3757
+ }
3748
3758
}
3749
3759
if (pClass->HasExplicitFieldOffsetLayout () && pClass->HasOverlaidField ())
3750
3760
ret |= CORINFO_FLG_OVERLAPPING_FIELDS;
You can’t perform that action at this time.
0 commit comments