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

StackType mismatch in StLoc because of unknown type #1635

Closed
greenozon opened this issue Aug 12, 2019 · 2 comments

Comments

@greenozon
Copy link

commented Aug 12, 2019

ILSpy version 5.0.0.5069-preview4

Error decompiling @060017E4 ---.UpdateSyntaxTreeContent
in assembly --
 ---> ICSharpCode.ILSpy.AssertionFailedException: 
   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) in offset 6
   at ICSharpCode.Decompiler.IL.StLoc.CheckInvariant(ILPhase phase) in offset 121
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in offset 126
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in offset 8
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in offset 126
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in offset 8
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in offset 126
   at ICSharpCode.Decompiler.IL.ILFunction.CheckInvariant(ILPhase phase) in offset 533
   at ICSharpCode.Decompiler.IL.ILFunction.RunTransforms(IEnumerable`1 transforms, ILTransformContext context) in offset 114
   at ICSharpCode.Decompiler.IL.Transforms.DelegateConstruction.TransformDelegateConstruction(NewObj value, ILInstruction& target) in offset 558
   at ICSharpCode.Decompiler.IL.Transforms.DelegateConstruction.ICSharpCode.Decompiler.IL.Transforms.IILTransform.Run(ILFunction function, ILTransformContext context) in offset 143
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 596
-- continuing with outer exception (ICSharpCode.Decompiler.DecompilerException) --
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 1084
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 249
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 782
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompileTypes(IEnumerable`1 types, DecompileRun decompileRun, ITypeResolveContext decompilationContext, SyntaxTree syntaxTree) in offset 219
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileTypes(IEnumerable`1 types) in offset 201
   at ICSharpCode.Decompiler.CSharp.WholeProjectDecompiler.<>c__DisplayClass34_0.<WriteCodeFilesInProject>b__2(IGrouping`2 file) in offset 69
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1() in offset 589
   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

https://www.sendspace.com/file/jjv9yw

@siegfriedpammer siegfriedpammer changed the title assert at ICSharpCode.Decompiler.IL.StLoc.CheckInvariant(ILPhase phase) StackType mismatch in StLoc Aug 12, 2019

@siegfriedpammer

This comment has been minimized.

Copy link
Member

commented Aug 12, 2019

stloc <UpdateSyntaxTreeContent>b__443_0V_0(dynamic.invokeconstructor .ctor([flags: UseCompileTimeType, IsStaticType, name: ] ldloc <UpdateSyntaxTreeContent>b__443_0S_114, [flags: None, name: ] ldloc <UpdateSyntaxTreeContent>b__443_0S_158, [flags: None, name: ] dynamic.getmember Length([flags: None, name: ] ldloc ts)))

The ResultType of dynamic.invokeconstructor is O, but the variable <UpdateSyntaxTreeContent>b__443_0V_0 is StackType.Unknown. I guess the only fix for this is to insert another conv instruction?

@siegfriedpammer siegfriedpammer changed the title StackType mismatch in StLoc StackType mismatch in StLoc because of unknown type Aug 12, 2019

@dgrunwald

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

Hmm, is it even correct to assume O for dynamic.invokeconstructor?
What about new IntPtr((dynamic)x); ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.