Avoid calling prestub through wrong MethodDesc (#5439)
authorJohn Chen <jochen@microsoft.com>
Fri, 3 Jun 2016 04:59:01 +0000 (21:59 -0700)
committerJohn Chen <jochen@microsoft.com>
Fri, 3 Jun 2016 04:59:01 +0000 (21:59 -0700)
While fixing up a call from a Ready-to-Run method, we don't always
have the right implementation MethodDesc for the target of the call.
Thus it is potentially unsafe to DoPrestub using the MethodDesc we have,
causing a test failue (Loader.classloader_regressions_429802_CMain)
in issue #5366. This is fixed by not calling DoPrestub from
ExternalMethodFixupWorker.

src/vm/prestub.cpp

index 60f2e9a..83c4015 100644 (file)
@@ -2043,13 +2043,10 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
             // Note that we do not want to call code:MethodDesc::IsPointingToPrestub() here. It does not take remoting interception 
             // into account and so it would cause otherwise intercepted methods to be JITed. It is a compat issue if the JITing fails.
             //
-            if (DoesSlotCallPrestub(pCode))
+            if (!DoesSlotCallPrestub(pCode))
             {
-                ETWOnStartup(PrestubWorker_V1, PrestubWorkerEnd_V1);
-                pCode = pMD->DoPrestub(NULL);
+                pCode = PatchNonVirtualExternalMethod(pMD, pCode, pImportSection, pIndirection);
             }
-
-            pCode = PatchNonVirtualExternalMethod(pMD, pCode, pImportSection, pIndirection);
         }
     }