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

Assertion fails after pinned region detection in System.Data.dll #2056

Closed
siegfriedpammer opened this issue Jul 7, 2020 · 2 comments
Closed
Labels
Bug C++/CLI Problem decompiling mixed-mode assemblies Decompiler The decompiler engine itself

Comments

@siegfriedpammer
Copy link
Member

Input code

C:\WINDOWS\Microsoft.NET\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll
@0600009C ADALNativeWrapper.ADALGetAccessToken

Erroneous output

ICSharpCode.ILSpy.AssertionFailedException: Container should not have any unreachable blocks
   at ICSharpCode.ILSpy.ILSpyTraceListener.Fail(String message, String detailMessage) in ILSpyTraceListener.cs:line 82
   at ICSharpCode.ILSpy.ILSpyTraceListener.Fail(String message) in ILSpyTraceListener.cs:line 47
   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 187
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 79
   at ICSharpCode.Decompiler.IL.ILFunction.CheckInvariant(ILPhase phase) in ILFunction.cs:line 252
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1329

Expected output

no assertion

Details

  • Product in use: ILSpy
  • Version in use: master
  • Occurs after pinned region detection
@siegfriedpammer siegfriedpammer added Bug Decompiler The decompiler engine itself C# Fixed labels Jul 7, 2020
@dgrunwald dgrunwald removed the Fixed label Jul 8, 2020
@dgrunwald dgrunwald added C++/CLI Problem decompiling mixed-mode assemblies and removed C# labels Aug 8, 2020
@dgrunwald
Copy link
Member

This is C++/CLI code. C++/CLI pinned_ptr really doesn't map cleanly to C# fixed statements :(
Block IL_00b8 pins the contents of a string. There is no unpin instruction (the pin is valid for the remainder of the function).
Note how IL_00b8 can be bypassed via the IL_00a0->IL_00c5 edge; so it's unclear whether the remainder of the function should be inside or outside the fixed statement.
ILSpy2056

@dgrunwald
Copy link
Member

The assertion refers to IL_00c3 which apparently gets clones into the pinned region when it should be moved into it because it's not reachable from outside the pinned region.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2020
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Aug 8, 2021
…re the clone cleanup

Otherwise the to-be-removed branch could keep an soon-to-be-unreachable block alive outside the pinned region.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug C++/CLI Problem decompiling mixed-mode assemblies Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

2 participants