summaryrefslogtreecommitdiff
path: root/src/vm/methodtablebuilder.cpp
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2019-06-10 16:33:42 +0200
committerGitHub <noreply@github.com>2019-06-10 16:33:42 +0200
commit8f3aa314cc9c03f9bff54661d6607087bc3d4030 (patch)
tree2fb63839e607618aed8f621db0851a8d22e3ab35 /src/vm/methodtablebuilder.cpp
parent82222f6f39f08f0e9d5686b65afce3520cc5ecd0 (diff)
downloadcoreclr-8f3aa314cc9c03f9bff54661d6607087bc3d4030.tar.gz
coreclr-8f3aa314cc9c03f9bff54661d6607087bc3d4030.tar.bz2
coreclr-8f3aa314cc9c03f9bff54661d6607087bc3d4030.zip
Fix field offset computation for large version bubble (#25029)
There was a discrepancy in field offset calculations at crossgen time and at runtime in some rare cases due to the alignment of a derived class offset. The issue happened due to MethodTableBuilder::NeedsAlignedBaseOffset not taking into account the fact that the module of the parent and child class can both be in large version bubble. We also had a bug in the PEDecoder::GetNativeManifestMetadata. When it was called for regular crossgened image without large version bubble, it left the pDir uninitialized due to the fact that there was no READYTORUN_SECTION_MANIFEST_METADATA. And then it tried to dereference that.
Diffstat (limited to 'src/vm/methodtablebuilder.cpp')
-rw-r--r--src/vm/methodtablebuilder.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp
index 31c4b0a5ee..2a59be4f33 100644
--- a/src/vm/methodtablebuilder.cpp
+++ b/src/vm/methodtablebuilder.cpp
@@ -11302,6 +11302,12 @@ BOOL MethodTableBuilder::NeedsAlignedBaseOffset()
if (IsValueClass())
return FALSE;
+ MethodTable * pParentMT = GetParentMethodTable();
+
+ // Trivial parents
+ if (pParentMT == NULL || pParentMT == g_pObjectClass)
+ return FALSE;
+
// Always use the ReadyToRun field layout algorithm if the source IL image was ReadyToRun, independent on
// whether ReadyToRun is actually enabled for the module. It is required to allow mixing and matching
// ReadyToRun images with NGen.
@@ -11312,17 +11318,31 @@ BOOL MethodTableBuilder::NeedsAlignedBaseOffset()
return FALSE;
}
- MethodTable * pParentMT = GetParentMethodTable();
-
- // Trivial parents
- if (pParentMT == NULL || pParentMT == g_pObjectClass)
- return FALSE;
-
if (pParentMT->GetModule() == GetModule())
{
if (!pParentMT->GetClass()->HasLayoutDependsOnOtherModules())
return FALSE;
}
+ else
+ {
+#ifdef FEATURE_READYTORUN_COMPILER
+ if (IsReadyToRunCompilation())
+ {
+ if (pParentMT->GetModule()->IsInCurrentVersionBubble())
+ {
+ return FALSE;
+ }
+ }
+#else // FEATURE_READYTORUN_COMPILER
+ if (GetModule()->GetFile()->IsILImageReadyToRun())
+ {
+ if (GetModule()->IsInSameVersionBubble(pParentMT->GetModule()))
+ {
+ return FALSE;
+ }
+ }
+#endif // FEATURE_READYTORUN_COMPILER
+ }
return TRUE;
}