Sitelet https://github.com/SixLabors/ImageSharp/issues/2743
Skip to content

AccessViolationException when loading corrupt GIF #2743

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.4

Other ImageSharp packages and versions

N/A

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.NET 8.0.4

Description

Opening the attached GIF causes an AccessViolatonException, and then a long hang (up to an hour) while the process tries to read GC information.

CoreCLR Version: 8.0.424.16909
.NET Version: 8.0.4
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException: Arg_AccessViolationException
Stack:
   at System.Resources.ResourceManager.GetFirstResourceSet(System.Globalization.CultureInfo)
   at System.Resources.ResourceManager.GetString(System.String, System.Globalization.CultureInfo)
   at System.SR.InternalGetResourceString(System.String)
   at System.SR.GetResourceString(System.String)
   at System.Exception.ToString()
   at System.Buffers.SharedArrayPool`1[[System.Char, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Rent(Int32)
   at System.Runtime.CompilerServices.DefaultInterpolatedStringHandler..ctor(Int32, Int32)
   at System.SR.InternalGetResourceString(System.String)
   at System.SR.GetResourceString(System.String)
   at System.AccessViolationException..ctor()
   at System.Resources.ResourceManager.GetFirstResourceSet(System.Globalization.CultureInfo)
   at System.Resources.ResourceManager.GetString(System.String, System.Globalization.CultureInfo)
   at System.SR.InternalGetResourceString(System.String)
   at System.SR.GetResourceString(System.String)
   at System.AccessViolationException..ctor()
   at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Add(System.__Canon)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.ReadFrameMetadata(SixLabors.ImageSharp.IO.BufferedReadStream, System.Collections.Generic.List`1<SixLabors.ImageSharp.Metadata.ImageFrameMetadata>, SixLabors.ImageSharp.Metadata.ImageFrameMetadata ByRef)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.Identify(SixLabors.ImageSharp.IO.BufferedReadStream, System.Threading.CancellationToken)
   at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Identify(SixLabors.ImageSharp.Formats.IImageDecoderInternals, SixLabors.ImageSharp.Configuration, System.IO.Stream, System.Threading.CancellationToken)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoder.Identify(SixLabors.ImageSharp.Formats.DecoderOptions, System.IO.Stream, System.Threading.CancellationToken)
   at SixLabors.ImageSharp.Formats.ImageDecoder+<>c__DisplayClass4_0.<Identify>b__0(System.IO.Stream)
   at SixLabors.ImageSharp.Formats.ImageDecoder.<WithSeekableStream>g__PeformActionAndResetPosition|11_0[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.IO.Stream, Int64, <>c__DisplayClass11_0`1<System.__Canon> ByRef)
   at SixLabors.ImageSharp.Formats.ImageDecoder.WithSeekableStream[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](SixLabors.ImageSharp.Formats.DecoderOptions, System.IO.Stream, System.Func`2<System.IO.Stream,System.__Canon>)
   at SixLabors.ImageSharp.Formats.ImageDecoder.Identify(SixLabors.ImageSharp.Formats.DecoderOptions, System.IO.Stream)
   at SixLabors.ImageSharp.Image.InternalIdentify(SixLabors.ImageSharp.Formats.DecoderOptions, System.IO.Stream)
   at SixLabors.ImageSharp.Image+<>c__DisplayClass76_0.<Identify>b__0(System.IO.Stream)
   at SixLabors.ImageSharp.Image.WithSeekableStream[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](SixLabors.ImageSharp.Formats.DecoderOptions, System.IO.Stream, System.Func`2<System.IO.Stream,System.__Canon>)
   at SixLabors.ImageSharp.Image.Identify(SixLabors.ImageSharp.Formats.DecoderOptions, System.IO.Stream)
   at SixLabors.ImageSharp.Image.Identify(System.IO.Stream)

Steps to Reproduce

Try to read the image e.g.
var imageInfo = Image.Identify("9A71AFA18DE4DB335FCDF07CC6F88ED9.gif");
or
using var image = Image.Load("9A71AFA18DE4DB335FCDF07CC6F88ED9.gif");

Images

9A71AFA18DE4DB335FCDF07CC6F88ED9

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions