Skip to content

Assert in ILInlining.CanMoveInto from IndexRangeTransform #2073

@yyjdelete

Description

@yyjdelete

Steps to reproduce

Try decompile any of the below methods from netcoreapp3.1/5.0 with C#8.0(Ranges) enabled.

[System.Net.Primitives]System.Net.SocketAddress.ToString()
[System.Diagnostics.Process]System.Diagnostics.Process.GetMainWindowTitle()
[System.Security.Cryptography.Encoding]System.Security.Cryptography.PemEncoding.TryFind(...)//5.0 only
[System.Security.Cryptography.Pkcs]System.Security.Cryptography.Asn1.AsnWriter.WriteNamedBitList(Asn1Tag, ulong)//5.0 only
[System.Private.Uri]System.IPv6AddressHelper.ParseCanonicalName()

Error message shown

   at ICSharpCode.Decompiler.IL.Transforms.ILInlining.CanMoveInto(ILInstruction expressionBeingMoved, ILInstruction stmt, ILInstruction targetLoad)
   at ICSharpCode.Decompiler.IL.Transforms.IndexRangeTransform.<ICSharpCode.Decompiler.IL.Transforms.IStatementTransform.Run>g__TransformSlicing|2_1(Boolean sliceLengthWasMisdetectedAsStartOffset, <>c__DisplayClass2_0&)
   at ICSharpCode.Decompiler.IL.Transforms.IndexRangeTransform.<ICSharpCode.Decompiler.IL.Transforms.IStatementTransform.Run>g__TransformIndexing|2_0(<>c__DisplayClass2_0&)
   at ICSharpCode.Decompiler.IL.Transforms.IndexRangeTransform.ICSharpCode.Decompiler.IL.Transforms.IStatementTransform.Run(Block block, Int32 pos, StatementTransformContext context)
   at ICSharpCode.Decompiler.IL.Transforms.StatementTransform.Run(Block block, BlockTransformContext context)
   at ICSharpCode.Decompiler.IL.Block.RunTransforms(IEnumerable`1 transforms, BlockTransformContext context)
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.VisitBlock(ControlFlowNode cfgNode, BlockTransformContext context)
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.VisitBlock(ControlFlowNode cfgNode, BlockTransformContext context)
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.VisitBlock(ControlFlowNode cfgNode, BlockTransformContext context)
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.VisitBlock(ControlFlowNode cfgNode, BlockTransformContext context)
   at ICSharpCode.Decompiler.IL.Transforms.BlockILTransform.Run(ILFunction function, ILTransformContext context)
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext)

Details

  • Product in use: ILSpy
  • Version in use: 6.0.0.5879(5459d6b, master)
  • Any other relevant information to the issue, or your interest in contributing a fix.

This is an new assert added in #2069 and not in 6.0.0.5836
The new validate code seems useful for System.Diagnostics.Process.GetMainWindowTitle(), only the new version can proper decompile the fixed block in the method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions