SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.39k stars 851 forks source link

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

Closed Erik-White closed 5 months ago

Erik-White commented 6 months ago

Prerequisites

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

Erik-White commented 5 months ago

@JimBobSquarePants Thanks for your lightning fast response! Do you have an estimate for when you will be able to push a new release with the fix?

JimBobSquarePants commented 5 months ago

Not a problem! We plan a proper release this week but in the interim there are nightlies you can try. The feed is linked from our readme.

Erik-White commented 5 months ago

Thanks for the updated release!