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

ICSharpCode.ILSpy.AssertionFailedException: Container should not have any unreachable blocks #2533

Closed
greenozon opened this issue Oct 31, 2021 · 1 comment
Labels

Comments

@greenozon
Copy link

Steps to reproduce

  1. Save project

Error message shown

Error decompiling @06000B7C SharpSvn.Implementation.SshConnection.VerifySshHost
in assembly "C:\1\SharpSvn.dll"
 ---> ICSharpCode.ILSpy.AssertionFailedException: Container should not have any unreachable blocks
   at ICSharpCode.ILSpy.ILSpyTraceListener.Fail(String message, String detailMessage) in offset 380
   at ICSharpCode.ILSpy.ILSpyTraceListener.Fail(String message) in offset 9
   at System.Diagnostics.TraceInternal.Fail(String message) in offset 55
   at System.Diagnostics.Debug.Assert(Boolean condition, String message) in offset 7
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 202
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.PinnedRegion.CheckInvariant(ILPhase phase) in Instructions.cs:line 1036
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.PinnedRegion.CheckInvariant(ILPhase phase) in Instructions.cs:line 1036
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.PinnedRegion.CheckInvariant(ILPhase phase) in Instructions.cs:line 1036
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.ILFunction.CheckInvariant(ILPhase phase) in ILFunction.cs:line 255
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1565
-- 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 1601
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1479
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1309
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompileTypes(IEnumerable`1 types, DecompileRun decompileRun, ITypeResolveContext decompilationContext, SyntaxTree syntaxTree) in CSharpDecompiler.cs:line 574
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileTypes(IEnumerable`1 types) in CSharpDecompiler.cs:line 894
   at ICSharpCode.Decompiler.CSharp.ProjectDecompiler.WholeProjectDecompiler.<>c__DisplayClass45_0.<WriteCodeFilesInProject>b__2(IGrouping`2 file) in WholeProjectDecompiler.cs:line 239
   at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1() in offset 713
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) in offset 6
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>) in offset 134

Details

ILSpy version 7.2.0.6689-preview1
.NET version 4.8.3928.0
SharpSvn.zip

@greenozon greenozon added the Bug label Oct 31, 2021
dgrunwald added a commit that referenced this issue Nov 13, 2021
…to be created with the wrong entry point if the original IL had blocks in an unusual order
@dgrunwald
Copy link
Member

The control flow of this function is not easy to understand.
I've put together the CFGs of the various try-finally constructs here: VerifySshHost

I've traced the problem to the loop at IL_033e, which seems to be an inlined wcscmp.
I've fixed the bug in DetectPinnedRegions that triggered this assertion.

Decompilation now gets past DetectPinnedRegions, but still fails with a different assertion in loop detection.

ElektroKill added a commit to dnSpyEx/ILSpy that referenced this issue Jan 2, 2022
…ed regions to be created with the wrong entry point if the original IL had blocks in an unusual order
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Jan 2, 2022
…ocks without ILRange.

These blocks could trigger assertions if LoopDetection was creating a loop BlockContainer from them (BlockContainers have an assertion requiring an ILRange).

Closes icsharpcode#2533 and icsharpcode#2457.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants