As part of #54580, I've discovered an alloc/decalloc mismatch in CoreCLR.
We sometimes allocate space for MethodTable::MethodData objects with new[] instead of new, but always delete with delete.
Allocation:
|
MethodData *pData = NULL; |
|
if (pMTDecl == pMTImpl) { |
|
if (pMTDecl->IsInterface()) { |
|
pData = new MethodDataInterface(pMTDecl); |
|
} |
|
else { |
|
UINT32 cb = MethodDataObject::GetObjectSize(pMTDecl); |
|
NewArrayHolder<BYTE> pb(new BYTE[cb]); |
|
MethodDataHolder h(FindParentMethodDataHelper(pMTDecl)); |
|
pData = new (pb.GetValue()) MethodDataObject(pMTDecl, h.GetValue()); |
|
pb.SuppressRelease(); |
|
} |
|
} |
|
else { |
|
pData = GetMethodDataHelper( |
|
NULL, |
|
0, |
|
pMTDecl, |
|
pMTImpl); |
|
} |
Dealloc:
|
ULONG MethodTable::MethodData::Release() |
|
{ |
|
LIMITED_METHOD_CONTRACT; |
|
//@TODO: Must adjust this to use an alternate allocator so that we don't |
|
//@TODO: potentially cause deadlocks on the debug thread. |
|
SUPPRESS_ALLOCATION_ASSERTS_IN_THIS_SCOPE; |
|
ULONG cRef = (ULONG) InterlockedDecrement((LONG*)&m_cRef); |
|
if (cRef == 0) { |
|
delete this; |
|
} |
|
return (cRef); |
|
} |
As part of #54580, I've discovered an alloc/decalloc mismatch in CoreCLR.
We sometimes allocate space for
MethodTable::MethodDataobjects withnew[]instead ofnew, but always delete withdelete.Allocation:
runtime/src/coreclr/vm/methodtable.cpp
Lines 8544 to 8563 in 0416c34
Dealloc:
runtime/src/coreclr/vm/methodtable.cpp
Lines 7901 to 7912 in 0416c34