From 8aa0869eb9153429091fdba49469d89ec33092cb Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Wed, 28 Nov 2018 06:36:59 +0100 Subject: Fix ILStubCache allocation for collectible assemblies (#21188) The ILStubCache was being allocated per domain unless the domain was a compilation AppDomain. This is wrong for collectible assemblies, since after an assembly is collected, the cache keeps stale entries referring to already deleted MethodTables. The fix is to make ILStubChange per LoaderAllocator instead (and keep the per module instances for compilation AppDomain). --- src/vm/loaderallocator.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/vm/loaderallocator.hpp') diff --git a/src/vm/loaderallocator.hpp b/src/vm/loaderallocator.hpp index c560c14567..0dded91c02 100644 --- a/src/vm/loaderallocator.hpp +++ b/src/vm/loaderallocator.hpp @@ -18,6 +18,7 @@ class FuncPtrStubs; #include "qcall.h" +#include "ilstubcache.h" #define VPTRU_LoaderAllocator 0x3200 @@ -178,6 +179,9 @@ protected: // The cache is keyed by MethodDesc pointers. UMEntryThunkCache * m_pUMEntryThunkCache; + // IL stub cache with fabricated MethodTable parented by a random module in this LoaderAllocator. + ILStubCache m_ILStubCache; + public: BYTE *GetVSDHeapInitialBlock(DWORD *pSize); BYTE *GetCodeHeapInitialBlock(const BYTE * loAddr, const BYTE * hiAddr, DWORD minimumSize, DWORD *pSize); @@ -519,6 +523,17 @@ public: UMEntryThunkCache *GetUMEntryThunkCache(); #endif + + static LoaderAllocator* GetLoaderAllocator(ILStubCache* pILStubCache) + { + return CONTAINING_RECORD(pILStubCache, LoaderAllocator, m_ILStubCache); + } + + ILStubCache* GetILStubCache() + { + LIMITED_METHOD_CONTRACT; + return &m_ILStubCache; + } }; // class LoaderAllocator typedef VPTR(LoaderAllocator) PTR_LoaderAllocator; -- cgit v1.2.3