diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp index 316e66673ba8..a31cd71a5c90 100644 --- a/src/vm/clsload.cpp +++ b/src/vm/clsload.cpp @@ -4192,6 +4192,15 @@ VOID ClassLoader::AddAvailableClassDontHaveLock(Module *pModule, #endif CrstHolder ch(&m_AvailableClassLock); + + // R2R pre-computes an export table and tries to avoid populating a class hash at runtime. However the profiler can + // still add new types on the fly by calling here. If that occurs we fallback to the slower path of creating the + // in memory hashtable as usual. + if (!pModule->IsResource() && pModule->GetAvailableClassHash() == NULL) + { + LazyPopulateCaseSensitiveHashTables(); + } + AddAvailableClassHaveLock( pModule, classdef, @@ -4386,7 +4395,9 @@ VOID ClassLoader::AddExportedTypeDontHaveLock(Module *pManifestModule, INJECT_FAULT(COMPlusThrowOM();); } CONTRACTL_END - + + CrstHolder ch(&m_AvailableClassLock); + // R2R pre-computes an export table and tries to avoid populating a class hash at runtime. However the profiler can // still add new types on the fly by calling here. If that occurs we fallback to the slower path of creating the // in memory hashtable as usual. @@ -4395,7 +4406,6 @@ VOID ClassLoader::AddExportedTypeDontHaveLock(Module *pManifestModule, LazyPopulateCaseSensitiveHashTables(); } - CrstHolder ch(&m_AvailableClassLock); AddExportedTypeHaveLock( pManifestModule, cl,