From fd4b12e82204542feb50205ae9558d53fcb6b24f Mon Sep 17 00:00:00 2001 From: EgorBo Date: Wed, 13 Sep 2023 22:36:21 +0200 Subject: [PATCH 1/2] Fix si.ibAllocated in FrozenObjectHeapManager --- src/coreclr/vm/frozenobjectheap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/frozenobjectheap.cpp b/src/coreclr/vm/frozenobjectheap.cpp index 41af231816a645..2d6c538c0dce2c 100644 --- a/src/coreclr/vm/frozenobjectheap.cpp +++ b/src/coreclr/vm/frozenobjectheap.cpp @@ -180,7 +180,7 @@ void FrozenObjectSegment::RegisterOrUpdate(uint8_t* current, size_t sizeCommited segment_info si; si.pvMem = m_pStart; si.ibFirstObject = sizeof(ObjHeader); - si.ibAllocated = (size_t)current; + si.ibAllocated = (size_t)current - (size_t)si.pvMem; si.ibCommit = sizeCommited; si.ibReserved = m_Size; From ce588845da7bfaa868aea5cb78e4b1ae7182aee1 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Thu, 14 Sep 2023 00:28:33 +0200 Subject: [PATCH 2/2] Add an assert --- src/coreclr/vm/frozenobjectheap.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/vm/frozenobjectheap.cpp b/src/coreclr/vm/frozenobjectheap.cpp index 2d6c538c0dce2c..8f11f3c8c74d64 100644 --- a/src/coreclr/vm/frozenobjectheap.cpp +++ b/src/coreclr/vm/frozenobjectheap.cpp @@ -184,6 +184,8 @@ void FrozenObjectSegment::RegisterOrUpdate(uint8_t* current, size_t sizeCommited si.ibCommit = sizeCommited; si.ibReserved = m_Size; + assert((size_t)current >= (size_t)si.pvMem); + // NOTE: RegisterFrozenSegment may take a GC lock inside. m_SegmentHandle = GCHeapUtilities::GetGCHeap()->RegisterFrozenSegment(&si); if (m_SegmentHandle == nullptr)