Skip to content

Commit 85e9e7b

Browse files
Fix access to m_pDynamicStaticsInfo (#97353)
- Remove race condition where it is possible that an updated dynamic statics info pointer is published without ensuring that the data is also considered written. - Use VolatileLoadWithoutBarrier at the read site (where locks are not taken) to ensure that there are no difficult to examine reads of this pointer.
1 parent bf10f73 commit 85e9e7b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/coreclr/vm/ceeload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ DWORD Module::AllocateDynamicEntry(MethodTable *pMT)
15671567
if (m_pDynamicStaticsInfo)
15681568
memcpy(pNewDynamicStaticsInfo, m_pDynamicStaticsInfo, sizeof(DynamicStaticsInfo) * m_maxDynamicEntries);
15691569

1570-
m_pDynamicStaticsInfo = pNewDynamicStaticsInfo;
1570+
VolatileStore(&m_pDynamicStaticsInfo, pNewDynamicStaticsInfo);
15711571
m_maxDynamicEntries = maxDynamicEntries;
15721572
}
15731573

src/coreclr/vm/ceeload.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ inline MethodTable* Module::GetDynamicClassMT(DWORD dynamicClassID)
463463
{
464464
LIMITED_METHOD_CONTRACT;
465465
_ASSERTE(m_cDynamicEntries > dynamicClassID);
466-
return m_pDynamicStaticsInfo[dynamicClassID].pEnclosingMT;
466+
return VolatileLoadWithoutBarrier(&m_pDynamicStaticsInfo)[dynamicClassID].pEnclosingMT;
467467
}
468468

469469
#ifdef FEATURE_CODE_VERSIONING

0 commit comments

Comments
 (0)