-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-VM-coreclruntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
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:
runtime/src/coreclr/vm/methodtable.cpp
Lines 8544 to 8563 in 0416c34
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:
runtime/src/coreclr/vm/methodtable.cpp
Lines 7901 to 7912 in 0416c34
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); | |
} |
Metadata
Metadata
Assignees
Labels
area-VM-coreclruntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner