Skip to content

Hard crash (Internal CLR error) with corrupt PNG image #2714

@Erik-White

Description

@Erik-White

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.1.3

Other ImageSharp packages and versions

N/A

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.NET 8.0

Description

Fatal error. Internal CLR error. (0x80131506)
at SixLabors.ImageSharp.PixelFormats.IPixel.ToRgba32(Rgba32& dest)
   at SixLabors.ImageSharp.Color.ToRgba32()
   at SixLabors.ImageSharp.Formats.Png.PngScanlineProcessor.ProcessInterlacedPaletteScanline[TPixel](FrameControl& frameControl, ReadOnlySpan`1 scanlineSpan, Span`1 rowSpan, UInt32 pixelOffset, UInt32 increment, Nullable`1 palette)
   at SixLabors.ImageSharp.Formats.Png.PngScanlineProcessor.ProcessPaletteScanline[TPixel](FrameControl& frameControl, ReadOnlySpan`1 scanlineSpan, Span`1 rowSpan, Nullable`1 palette)
   at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.ProcessDefilteredScanline[TPixel](FrameControl& frameControl, Int32 currentRow, ReadOnlySpan`1 scanline, ImageFrame`1 pixels, PngMetadata pngMetadata, Span`1 blendRowBuffer)
   at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.DecodePixelData[TPixel](FrameControl frameControl, DeflateStream compressedStream, ImageFrame`1 imageFrame, PngMetadata pngMetadata, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.ReadScanlines[TPixel](Int32 chunkLength, ImageFrame`1 image, PngMetadata pngMetadata, Func`1 getData, FrameControl& frameControl, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.Decode[TPixel](BufferedReadStream stream, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream, Func`3 largeImageExceptionFactory, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.Png.PngDecoder.Decode[TPixel](PngDecoderOptions options, Stream stream, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.Png.PngDecoder.Decode(PngDecoderOptions options, Stream stream, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.SpecializedImageDecoder`1.Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.ImageDecoder.<>c__DisplayClass1_0.<Decode>b__0(Stream s)
   at SixLabors.ImageSharp.Formats.ImageDecoder.<WithSeekableStream>g__PeformActionAndResetPosition|11_0[T](Stream s, Int64 position, <>c__DisplayClass11_0`1& )
   at SixLabors.ImageSharp.Formats.ImageDecoder.WithSeekableStream[T](DecoderOptions options, Stream stream, Func`2 action)
   at SixLabors.ImageSharp.Formats.ImageDecoder.Decode(DecoderOptions options, Stream stream)
   at SixLabors.ImageSharp.Image.Decode(DecoderOptions options, Stream stream)
   at SixLabors.ImageSharp.Image.<>c__DisplayClass80_0.<Load>b__0(Stream s)
   at SixLabors.ImageSharp.Image.WithSeekableStream[T](DecoderOptions options, Stream stream, Func`2 action)
   at SixLabors.ImageSharp.Image.Load(DecoderOptions options, Stream stream)
   at SixLabors.ImageSharp.Image.Load(DecoderOptions options, String path)
   at SixLabors.ImageSharp.Image.Load(String path)

Steps to Reproduce

Attempt to load the attached image e.g.

using var image = Image.Load("59cbc08a-f1c4-4e8d-b094-bba786b2cc3e.png");

Images

59cbc08a-f1c4-4e8d-b094-bba786b2cc3e

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions