summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-05-26 07:17:51 -0700
committerGitHub <noreply@github.com>2017-05-26 07:17:51 -0700
commita3c193780b8e055678feb06b2499cf8e7b41810c (patch)
tree47d4569d9e3265fee169071e0a013e2d4c18f89c /src
parent8a934c90711e0d1a915e309941a34db832395076 (diff)
downloadcoreclr-a3c193780b8e055678feb06b2499cf8e7b41810c.tar.gz
coreclr-a3c193780b8e055678feb06b2499cf8e7b41810c.tar.bz2
coreclr-a3c193780b8e055678feb06b2499cf8e7b41810c.zip
EETypeHashTable lookups can deadlock with GC during comparison with unrestored persisted TypeHandles (#11922)
Diffstat (limited to 'src')
-rw-r--r--src/vm/clsload.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp
index e0d8d73351..2e91672184 100644
--- a/src/vm/clsload.cpp
+++ b/src/vm/clsload.cpp
@@ -1337,6 +1337,9 @@ TypeHandle ClassLoader::LookupTypeKeyUnderLock(TypeKey *pKey,
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
+ // m_AvailableTypesLock has to be taken in cooperative mode to avoid deadlocks during GC
+ GCX_MAYBE_COOP_NO_THREAD_BROKEN(!IsGCThread());
+
CrstHolder ch(pLock);
return pTable->GetValue(pKey);
}
@@ -3742,6 +3745,9 @@ TypeHandle ClassLoader::PublishType(TypeKey *pTypeKey, TypeHandle typeHnd)
Module *pLoaderModule = ComputeLoaderModule(pTypeKey);
EETypeHashTable *pTable = pLoaderModule->GetAvailableParamTypes();
+ // m_AvailableTypesLock has to be taken in cooperative mode to avoid deadlocks during GC
+ GCX_COOP();
+
CrstHolder ch(&pLoaderModule->GetClassLoader()->m_AvailableTypesLock);
// The type could have been loaded by a different thread as side-effect of avoiding deadlocks caused by LoadsTypeViolation
@@ -3807,6 +3813,9 @@ TypeHandle ClassLoader::PublishType(TypeKey *pTypeKey, TypeHandle typeHnd)
Module *pModule = pTypeKey->GetModule();
mdTypeDef typeDef = pTypeKey->GetTypeToken();
+ // m_AvailableTypesLock has to be taken in cooperative mode to avoid deadlocks during GC
+ GCX_COOP();
+
CrstHolder ch(&pModule->GetClassLoader()->m_AvailableTypesLock);
// ! We cannot fail after this point.