Skip to content

Race condition on GraphicOptionsDefaultsExtensions.GetGraphicsOptions #1273

@DTTerastar

Description

@DTTerastar

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

Description

Occasionally I'm getting the following exception which appears to be a threading race:

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value)
at SixLabors.ImageSharp.GraphicOptionsDefaultsExtensions.GetGraphicsOptions(Configuration configuration)
at SixLabors.ImageSharp.GraphicOptionsDefaultsExtensions.GetGraphicsOptions(IImageProcessingContext context)
at Iol.Content.Services.ImageMutationExtensions.<>c__DisplayClass0_1.b__3(IImageProcessingContext x) in /agent/work/7cdd69e844c80f2c/src/Iol.Content/Services/ImageMutationExtensions.cs:line 54
at SixLabors.ImageSharp.Processing.ProcessingExtensions.ProcessingVisitor.Visit[TPixel](Image1 image) at Iol.Content.Services.ImageMutationExtensions.Mutate(Image image, List1 imageCommands) in /agent/work/7cdd69e844c80f2c/src/Iol.Content/Services/ImageMutationExtensions.cs:line 65

Steps to Reproduce

I don't have a good repro. It happens once every hour or so with hundreds of container starts under 100k rpm image hosting. But I do think the fix is to just move to a ConcurrentDictionary.

System Configuration

  • ImageSharp version:
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on):
  • .NET Framework version:
  • Additional information:

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