ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

Error decompiling async Begin/MoveNext methods: NullReferenceException in TransformExpressionTrees.BuildCall

Open amnesiaof opened this issue 2 months ago • 0 comments

Input code

Assembly: AME Beta.exe (TrustedUninstaller.GUI) Failed methods:

  • TrustedUninstaller.GUI.windows.IsoProgressDialog.Begin (@06000244)
  • TrustedUninstaller.GUI.windows.IsoProgressDialog.d__5.MoveNext (@0600089F)
  • TrustedUninstaller.GUI.windows.ProgressDialog.Begin (@060002BC)
  • TrustedUninstaller.GUI.windows.ProgressDialog.d__2.MoveNext (@06000985)

Cannot share assembly directly, but the issue occurs when decompiling async/lambda-heavy code in expression tree transforms.

Erroneous output

Error decompiling @06000244 TrustedUninstaller.GUI.windows.IsoProgressDialog.Begin: Object reference not set to an instance of an object.
---> System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.Decompiler.IL.InstructionCollection`1.AddRange(IEnumerable`1 values) in InstructionCollection.cs:line 196
   at ICSharpCode.Decompiler.IL.Transforms.TransformExpressionTrees.<>c__DisplayClass23_0.<ConvertCall>g__BuildCall|0() in TransformExpressionTrees.cs:line 830
   at ICSharpCode.Decompiler.IL.Transforms.TransformExpressionTrees.<>c__DisplayClass16_0.<ConvertInstruction>g__DoConvert|0() in TransformExpressionTrees.cs:line 378
   at ICSharpCode.Decompiler.IL.Transforms.TransformExpressionTrees.<>c__DisplayClass12_0.<ConvertLambda>g__BuildFunction|0() in TransformExpressionTrees.cs:line 238
   at ICSharpCode.Decompiler.IL.Transforms.TransformExpressionTrees.TryConvertExpressionTree(ILInstruction instruction, ILInstruction statement) in TransformExpressionTrees.cs:line 178

The decompiler crashes when trying to convert lambda expressions inside async methods to expression trees. Output contains error text instead of decompiled code for these 4 methods.

Details

  • Product in use: ILSpy
  • Version in use: ILSpy version 11.1.0.9782+a6909b2e1062d2404a52711926fa74030bd96119; .NET version 10.0.12-servicing.26422.108+95017c711e6afc1085133d440e42b4bd78155701
  • Additional info: The issue appears to be in TransformExpressionTrees.cs when building expression trees from async state machine methods. Similar to previously reported issues with expression tree decompilation.

amnesiaof avatar Sep 24 '26 12:09 amnesiaof