diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index 5a3576b4bf4498..becf93b49eca35 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -391,6 +391,8 @@ HRESULT EEClass::AddField(MethodTable* pMT, mdFieldDef fieldDef, FieldDesc** ppN LOG((LF_ENC, LL_INFO100, "EEClass::AddField Checking: %s mod:%p\n", pMod->GetDebugName(), pMod)); EETypeHashTable* paramTypes = pMod->GetAvailableParamTypes(); + CrstHolder ch(pMod->GetClassLoader()->GetAvailableTypesLock()); + EETypeHashTable::Iterator it(paramTypes); EETypeHashEntry* pEntry; while (paramTypes->FindNext(&it, &pEntry)) @@ -587,6 +589,8 @@ HRESULT EEClass::AddMethod(MethodTable* pMT, mdMethodDef methodDef, MethodDesc** LOG((LF_ENC, LL_INFO100, "EEClass::AddMethod Checking: %s mod:%p\n", pMod->GetDebugName(), pMod)); EETypeHashTable* paramTypes = pMod->GetAvailableParamTypes(); + CrstHolder ch(pMod->GetClassLoader()->GetAvailableTypesLock()); + EETypeHashTable::Iterator it(paramTypes); EETypeHashEntry* pEntry; while (paramTypes->FindNext(&it, &pEntry)) diff --git a/src/coreclr/vm/clsload.cpp b/src/coreclr/vm/clsload.cpp index 09b9b44bbeaee5..72ca527baa01c4 100644 --- a/src/coreclr/vm/clsload.cpp +++ b/src/coreclr/vm/clsload.cpp @@ -1735,7 +1735,7 @@ VOID ClassLoader::Init(AllocMemTracker *pamTracker) // This lock is taken within the classloader whenever we have to insert a new param. type into the table. m_AvailableTypesLock.Init( CrstAvailableParamTypes, - CRST_DEBUGGER_THREAD); + CrstFlags(CRST_DEBUGGER_THREAD | CRST_GC_NOTRIGGER_WHEN_TAKEN | CRST_UNSAFE_ANYMODE)); #ifdef _DEBUG CorTypeInfo::CheckConsistency(); diff --git a/src/coreclr/vm/clsload.hpp b/src/coreclr/vm/clsload.hpp index ee7a8ca2f9dac6..c50dd4a5fc7987 100644 --- a/src/coreclr/vm/clsload.hpp +++ b/src/coreclr/vm/clsload.hpp @@ -533,6 +533,13 @@ class ClassLoader public: + + CrstBase *GetAvailableTypesLock() + { + LIMITED_METHOD_CONTRACT; + return &m_AvailableTypesLock; + } + //#LoaderModule // LoaderModule determines in which module an item gets placed. // For everything except parameterized types and methods the choice is easy. diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 1605b213aa7081..08620b3c715375 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -10824,7 +10824,7 @@ VOID DECLSPEC_NORETURN RealCOMPlusThrowHR(HRESULT hr) CONTRACTL { THROWS; - DISABLED(GC_NOTRIGGER); // Must sanitize first pass handling to enable this + GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; @@ -10837,7 +10837,7 @@ VOID DECLSPEC_NORETURN RealCOMPlusThrowHR(HRESULT hr) // ! // ! COMPlusThrowHR(hr, kGetErrorInfo) - RealCOMPlusThrowHR(hr, (IErrorInfo*)NULL); + EX_THROW(EEMessageException, (hr)); } VOID DECLSPEC_NORETURN RealCOMPlusThrowHR(HRESULT hr, tagGetErrorInfo) @@ -10883,7 +10883,7 @@ VOID DECLSPEC_NORETURN RealCOMPlusThrowHR(HRESULT hr, UINT resID, LPCWSTR wszArg CONTRACTL { THROWS; - DISABLED(GC_NOTRIGGER); // Must sanitize first pass handling to enable this + GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END;