Fix Module::IsInSameVersionBubble contract (#25106)
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 12 Jun 2019 11:27:12 +0000 (13:27 +0200)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2019 11:27:12 +0000 (13:27 +0200)
* Fix Module::IsInSameVersionBubble contract

The function had an incorrect contract indicating that it cannot throw
and that it cannot trigger GC. This is not true in case the underlying
GetNativeAssemblyImport loads the manifest.
Change the contract to STANDARD_VM_CONTRACT

src/vm/ceeload.cpp

index 49d5fb5..b1ee606 100644 (file)
@@ -3420,22 +3420,16 @@ BOOL Module::IsInCurrentVersionBubble()
 //
 BOOL Module::IsInSameVersionBubble(Module *target)
 {
-    CONTRACT(BOOL)
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        MODE_ANY;
-    }
-    CONTRACT_END;
+    STANDARD_VM_CONTRACT;
 
     if (this == target)
     {
-        RETURN TRUE;
+        return TRUE;
     }
 
     if (!HasNativeOrReadyToRunImage())
     {
-        RETURN FALSE;
+        return FALSE;
     }
 
     // Check if the current module's image has native manifest metadata, otherwise the current->GetNativeAssemblyImport() asserts.
@@ -3443,7 +3437,7 @@ BOOL Module::IsInSameVersionBubble(Module *target)
     const void* pMeta = GetFile()->GetOpenedILimage()->GetNativeManifestMetadata(&cMeta);
     if (pMeta == NULL)
     {
-        RETURN FALSE;
+        return FALSE;
     }
 
     IMDInternalImport* pMdImport = GetNativeAssemblyImport();
@@ -3459,11 +3453,11 @@ BOOL Module::IsInSameVersionBubble(Module *target)
         hr = pMdImport->GetAssemblyRefProps(assemblyRef, NULL, NULL, &assemblyName, NULL, NULL, NULL, NULL);
         if (strcmp(assemblyName, targetName) == 0)
         {
-            RETURN TRUE;
+            return TRUE;
         }
     }
 
-    RETURN FALSE;
+    return FALSE;
 }
 #endif // FEATURE_READYTORUN && !FEATURE_READYTORUN_COMPILER