Skip to content

RAR dumps stack for BadImageFormatException when reading assembly  #8140

@danmoseley

Description

@danmoseley

RAR (or whatever is running) should not dump stack when reading an invalid assembly.

It looks like here

catch (ArgumentException)

should be catching BadImageFormatException as well as ArgumentException since that method intends to return the exception not throw it.

Image is too small. [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.Throw.ImageTooSmall() [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.PortableExecutable.SectionHeader..ctor(PEBinaryReader& reader) [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.PortableExecutable.PEHeaders.ReadSectionHeaders(PEBinaryReader& reader) [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.PortableExecutable.PEHeaders..ctor(Stream peStream, Int32 size, Boolean isLoadedImage) [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.PortableExecutable.PEReader.InitializePEHeaders() [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.PortableExecutable.PEReader.GetMetadataBlock() [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile) [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [...]
C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\Microsoft.Common.CurrentVersion.targets(2318,5): error MSB3246:    at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName) [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageHave yet to determine what bucket this goes in.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions