Fix inline tracking (#25062)
authorJan Vorlicek <janvorli@microsoft.com>
Tue, 11 Jun 2019 00:22:13 +0000 (02:22 +0200)
committerGitHub <noreply@github.com>
Tue, 11 Jun 2019 00:22:13 +0000 (02:22 +0200)
Inline tracking didn't correctly place the right key into the
inline tracking map for generics. The logic places the instantiated
methoddesc into the tracking map, and then attempts to find it by
looking up the uninstantiated form. This would generally be a silent
failure, but in unloadable assembly testing we have an assert that the
CrossLoaderAllocatorHash holds as keys items from a matching
LoaderAllocator.

This issue also results in an assert `key->GetLoaderAllocator() ==
m_pLoaderAllocator` in CrossLoaderAllocatorHash when the code is
running inside of a collectible AssemblyLoadContext.

src/vm/inlinetracking.cpp

index f4e055d..41aa3fc 100644 (file)
@@ -642,6 +642,8 @@ void JITInlineTrackingMap::AddInlining(MethodDesc *inliner, MethodDesc *inlinee)
 {
     LIMITED_METHOD_CONTRACT;
 
+    inlinee = inlinee->LoadTypicalMethodDefinition();
+
     CrstHolder holder(&m_mapCrst);
     AddInliningDontTakeLock(inliner, inlinee);
 }