Skip to content

Bad data can cause ILVerify to throw IndexOutOfRangeException #63227

@masonwheeler

Description

@masonwheeler

Description

While attempting to use ILVerify to diagnose a compiler output problem, it instead blew up in my face, dumping an IndexOutOfRangeException stack trace on me.

Reproduction Steps

  1. Install .NET 5.
  2. Install ILVerify.
  3. Download this test case and unzip it to a new folder.
  4. Open PowerShell and CD to that folder.
  5. ilverify .\testcase.dll -r "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.13\*.dll" -r "Boo.Lang.dll" (Adjust .NET 5 path as needed)

Expected behavior

A correct program should not throw "boneheaded exceptions."

A diagnostic tool should provide helpful diagnostic information about the nature of errors encountered.

Actual behavior

Error: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Internal.IL.ILImporter.CreateBasicBlock(Int32 offset)
   at Internal.IL.ILImporter.FindBasicBlocks()
   at Internal.IL.ILImporter.Verify()
   at ILVerify.Verifier.VerifyMethod(EcmaModule module, MethodIL methodIL, MethodDefinitionHandle methodHandle)
   at ILVerify.Verifier.VerifyMethods(EcmaModule module, IEnumerable`1 methodHandles)+MoveNext()
   at ILVerify.Verifier.Verify(PEReader peReader, MethodDefinitionHandle methodHandle)+MoveNext()
   at ILVerify.Program.VerifyMethods(PEReader peReader, EcmaModule module, String path, Int32& numErrors, Int32& verifiedMethodCounter, Int32& methodCounter)
   at ILVerify.Program.VerifyAssembly(PEReader peReader, EcmaModule module, String path)
   at ILVerify.Program.Run()
   at ILVerify.Program.Run(Options options)

Configuration

.NET 5, Windows 10, x64

Metadata

Metadata

Labels

Priority:2Work that is important, but not critical for the releasearea-Tools-ILVerificationIssues related to ilverify tool and IL verification in generalhelp wanted[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions