Skip to content

Commit 4ecef5f

Browse files
Free LOADERHANDLE DispatchMemberInfo dtor (#77570)
This is a regression from NETFX with the introduction of collectable assemblies in .NET Core 3.1 (dotnet/coreclr#20919). Co-authored-by: Aaron Robinson <[email protected]>
1 parent bdff556 commit 4ecef5f

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

src/coreclr/vm/dispatchinfo.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef int (__cdecl *UnicodeStringCompareFuncPtr)(const WCHAR *, const WCHAR *)
6666
//--------------------------------------------------------------------------------
6767
// The DispatchMemberInfo class implementation.
6868

69-
DispatchMemberInfo::DispatchMemberInfo(DispatchInfo *pDispInfo, DISPID DispID, SString& strName, OBJECTREF MemberInfoObj)
69+
DispatchMemberInfo::DispatchMemberInfo(DispatchInfo *pDispInfo, DISPID DispID, SString& strName)
7070
: m_DispID(DispID)
7171
, m_hndMemberInfo(NULL)
7272
, m_apParamMarshaler(NULL)
@@ -82,7 +82,7 @@ DispatchMemberInfo::DispatchMemberInfo(DispatchInfo *pDispInfo, DISPID DispID, S
8282
, m_pDispInfo(pDispInfo)
8383
, m_bLastParamOleVarArg(FALSE)
8484
{
85-
WRAPPER_NO_CONTRACT; // Calls to CreateHandle, above, means not a leaf contract
85+
WRAPPER_NO_CONTRACT;
8686
}
8787

8888
void DispatchMemberInfo::Neuter()
@@ -137,6 +137,9 @@ DispatchMemberInfo::~DispatchMemberInfo()
137137
if (m_pParamInOnly)
138138
delete [] m_pParamInOnly;
139139

140+
if (m_hndMemberInfo)
141+
m_pDispInfo->GetLoaderAllocator()->FreeHandle(m_hndMemberInfo);
142+
140143
// Clear the name of the member.
141144
m_strName.Clear();
142145
}
@@ -335,6 +338,11 @@ PTRARRAYREF DispatchMemberInfo::GetParameters()
335338
return ParamArray;
336339
}
337340

341+
OBJECTREF DispatchMemberInfo::GetMemberInfoObject()
342+
{
343+
return m_pDispInfo->GetLoaderAllocator()->GetHandleValue(m_hndMemberInfo);
344+
}
345+
338346
void DispatchMemberInfo::MarshalParamNativeToManaged(int iParam, VARIANT *pSrcVar, OBJECTREF *pDestObj)
339347
{
340348
CONTRACTL
@@ -1013,19 +1021,6 @@ void DispatchMemberInfo::SetUpDispParamAttributes(int iParam, MarshalInfo* Info)
10131021
m_pParamInOnly[iParam] = ( Info->IsIn() && !Info->IsOut() );
10141022
}
10151023

1016-
#ifndef DACCESS_COMPILE
1017-
OBJECTREF DispatchMemberInfo::GetMemberInfoObject()
1018-
{
1019-
return m_pDispInfo->GetLoaderAllocator()->GetHandleValue(m_hndMemberInfo);
1020-
}
1021-
1022-
void DispatchMemberInfo::ClearMemberInfoObject()
1023-
{
1024-
m_pDispInfo->GetLoaderAllocator()->SetHandleValue(m_hndMemberInfo, NULL);
1025-
}
1026-
#endif // DACCESS_COMPILE
1027-
1028-
10291024
//--------------------------------------------------------------------------------
10301025
// The DispatchInfo class implementation.
10311026

@@ -1162,7 +1157,7 @@ DispatchMemberInfo* DispatchInfo::CreateDispatchMemberInfoInstance(DISPID DispID
11621157
}
11631158
CONTRACT_END;
11641159

1165-
DispatchMemberInfo* pInfo = new DispatchMemberInfo(this, DispID, strMemberName, MemberInfoObj);
1160+
DispatchMemberInfo* pInfo = new DispatchMemberInfo(this, DispID, strMemberName);
11661161
pInfo->SetHandle(GetLoaderAllocator()->AllocateHandle(MemberInfoObj));
11671162

11681163
RETURN pInfo;
@@ -3291,8 +3286,7 @@ DispatchMemberInfo* DispatchExInfo::CreateDispatchMemberInfoInstance(DISPID Disp
32913286
}
32923287
CONTRACT_END;
32933288

3294-
DispatchMemberInfo* pInfo = new DispatchMemberInfo(this, DispID, strMemberName, MemberInfoObj);
3295-
3289+
DispatchMemberInfo* pInfo = new DispatchMemberInfo(this, DispID, strMemberName);
32963290
pInfo->SetHandle(GetLoaderAllocator()->AllocateHandle(MemberInfoObj));
32973291

32983292
RETURN pInfo;

src/coreclr/vm/dispatchinfo.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ enum CultureAwareStates
5454
// This structure represents a dispatch member.
5555
struct DispatchMemberInfo
5656
{
57-
DispatchMemberInfo(DispatchInfo *pDispInfo, DISPID DispID, SString& strName, OBJECTREF MemberInfoObj);
57+
DispatchMemberInfo(DispatchInfo *pDispInfo, DISPID DispID, SString& strName);
5858
~DispatchMemberInfo();
5959

6060
// Helper method to ensure the entry is initialized.
@@ -148,10 +148,7 @@ struct DispatchMemberInfo
148148
return m_bRequiresManagedCleanup;
149149
}
150150

151-
#ifndef DACCESS_COMPILE
152151
OBJECTREF GetMemberInfoObject();
153-
void ClearMemberInfoObject();
154-
#endif // DACCESS_COMPILE
155152

156153
// Parameter marshaling methods.
157154
void MarshalParamNativeToManaged(int iParam, VARIANT *pSrcVar, OBJECTREF *pDestObj);

0 commit comments

Comments
 (0)