Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
greenozon opened this issue Nov 11, 2023 · 2 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@greenozon
Copy link

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 greenozon added Bug Decompiler The decompiler engine itself labels Nov 11, 2023
@ElektroKill
Copy link
Contributor

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.

@greenozon
Copy link
Author

Still reproducible on the following setup:

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

@siegfriedpammer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

2 participants