ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

Assert at ICSharpCode.Decompiler.IL.ControlFlow.YieldReturnDecompiler.<ConvertBody>

Open greenozon opened this issue 2 years ago • 2 comments

Input code

save project

Erroneous output

Error decompiling @06000170 -----
in assembly "C:\IL_errs\err139.dll"
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.Decompiler.IL.ControlFlow.YieldReturnDecompiler.<ConvertBody>g__ConvertBranchAfterYieldReturn|35_0(Block newBlock, Block oldBlock, Int32 pos, <>c__DisplayClass35_0&) in YieldReturnDecompiler.cs:line 1016
   at ICSharpCode.Decompiler.IL.ControlFlow.YieldReturnDecompiler.ConvertBody(BlockContainer oldBody, StateRangeAnalysis rangeAnalysis) in YieldReturnDecompiler.cs:line 894
   at ICSharpCode.Decompiler.IL.ControlFlow.YieldReturnDecompiler.AnalyzeMoveNext(ILFunction function) in YieldReturnDecompiler.cs:line 786
   at ICSharpCode.Decompiler.IL.ControlFlow.YieldReturnDecompiler.Run(ILFunction function, ILTransformContext context) in YieldReturnDecompiler.cs:line 152
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1737
-- continuing with outer exception (ICSharpCode.Decompiler.DecompilerException) --
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1773
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1622
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.<>c__DisplayClass74_0.<DoDecompile>g__DoDecompileMember|0(IEntity entity, RecordDecompiler recordDecompiler, PartialTypeInfo partialType) in CSharpDecompiler.cs:line 1497
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1364
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(IEnumerable`1 definitions) in CSharpDecompiler.cs:line 1033
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(EntityHandle[] definitions) in CSharpDecompiler.cs:line 1005
   at ICSharpCode.ILSpy.CSharpLanguage.DecompileType(ITypeDefinition type, ITextOutput output, DecompilationOptions options) in offset 93
   at ICSharpCode.ILSpy.TreeNodes.TypeTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options) in offset 8
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) in offset 122
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass53_0.<DecompileAsync>b__0() in offset 20

Details

  • ILSpy version 8.2.0.7537
  • .NET version 6.0.23-servicing.23480.2+e0f0de876a67755a2c6cd2dc730c13f5959bdea8

err139.zip

greenozon avatar Nov 11 '23 18:11 greenozon

This file is partially obfuscated with control flow obfuscation which interferes with the decompiler. image These methods all utilize an unassigned field in the class. This is typical obfuscation for the .NET Reactor obfuscator. image

For successful decompilation, you would need to remove this obfuscation. However, I think the decompiler should not completely crash when encountering this unexpected difference in the state machine code.

ElektroKill avatar Nov 12 '23 10:11 ElektroKill

Still reproducible on the following setup:

ILSpy version 9.0.0.7612-preview1
.NET version 8.0.3+9f4b1f5d664afdfc80e1508ab7ed099dff210fbd

@siegfriedpammer

greenozon avatar Mar 30 '24 13:03 greenozon