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

.NET 5 RC2: "Analyze/Used By" throws BadImageFormatException #2197

Closed
albahari opened this issue Oct 23, 2020 · 2 comments
Closed

.NET 5 RC2: "Analyze/Used By" throws BadImageFormatException #2197

albahari opened this issue Oct 23, 2020 · 2 comments

Comments

@albahari
Copy link

Steps to reproduce

  1. Load the .NET 5 RC2 assemblies
  2. Navigate to the System.Runtime.CompilerServices.CallConvCdecl type
  3. Ctrl+R for Analyze, expand 'Used By'

Error message shown

System.BadImageFormatException: Expected signature header for 'Property' or 'Method', but found '9' (0x09).
   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.CheckMethodOrPropertyHeader(SignatureHeader header)
   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeMethodSignature(BlobReader& blobReader)
   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeType(BlobReader& blobReader, Boolean allowTypeSpecifications, Int32 typeCode)
   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeType(BlobReader& blobReader, Boolean allowTypeSpecifications)
   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeTypeSequence(BlobReader& blobReader)
   at System.Reflection.Metadata.StandaloneSignature.DecodeLocalSignature[TType,TGenericContext](ISignatureTypeProvider`2 provider, TGenericContext genericContext)
   at ICSharpCode.Decompiler.TypeSystem.MetadataModule.DecodeLocalSignature(StandaloneSignatureHandle handle, GenericContext genericContext)
   at ICSharpCode.ILSpy.Analyzers.Builtin.TypeUsedByAnalyzer.ScanMethodBody(TypeDefinitionUsedVisitor visitor, IMethod method, MethodBodyBlock methodBody, AnalyzerContext context)
   at ICSharpCode.ILSpy.Analyzers.Builtin.TypeUsedByAnalyzer.<ScanType>d__1.MoveNext()
   at ICSharpCode.ILSpy.Analyzers.Builtin.TypeUsedByAnalyzer.<Analyze>d__0.MoveNext()
   at ICSharpCode.ILSpy.Analyzers.AnalyzerSearchTreeNode.<FetchChildren>d__10.MoveNext()
   at ICSharpCode.ILSpy.TreeNodes.ThreadingSupport.<>c__DisplayClass5_0.<LoadChildren>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Details

  • Product in use: ILSpy version 6.2.1.6137
@albahari albahari added the Bug label Oct 23, 2020
@siegfriedpammer
Copy link
Member

This is because ILSpy does not yet use a version of System.Reflection.Metadata that supports the new function pointer signature extensions. I believe @dgrunwald recently experimented with updating to a preview of SRM.

@dgrunwald
Copy link
Member

This particular crash should already be fixed in ILSpy master, as we've updated to a pre-release version of SRM 5 there.

However in general I think the analyzer should be catching BadImageFormatException and continue analyzing as much as possible. (such exceptions can also happen with obfuscated assemblies)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants