Avoid instantiating abstract class (dotnet/coreclr#27589)
authorAndrew Au <andrewau@microsoft.com>
Mon, 4 Nov 2019 23:43:56 +0000 (15:43 -0800)
committerGitHub <noreply@github.com>
Mon, 4 Nov 2019 23:43:56 +0000 (15:43 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/0b441193b7b701c4b68d758c4798f28241cfb9e3

src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs

index e91cc07..0fefb69 100644 (file)
@@ -758,6 +758,11 @@ namespace Internal.JitInterface
         private CorInfoHelpFunc getNewHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, byte* pHasSideEffects = null)
         {
             TypeDesc type = HandleToObject(pResolvedToken.hClass);
+            MetadataType metadataType = type as MetadataType;
+            if (metadataType != null && metadataType.IsAbstract)
+            {
+                ThrowHelper.ThrowInvalidProgramException(ExceptionStringID.InvalidProgramSpecific, HandleToObject(callerHandle));
+            }
 
             if (pHasSideEffects != null)
             {