SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET

Home Page:https://sixlabors.com/products/imagesharp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Application crashes when trying to mutate an image

DigitalEntry opened this issue · comments

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

4.0.0-alpha.0.1

Other ImageSharp packages and versions

ImageSharp.Drawing 2.0.2-alpha.0.1

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

8.0

Description

The application just crashes when trying to mutate an image. I have tried multiple images and have gotten the same error. I have tried on versions 1.0.4, 2.1.6, 3.1.0 and now 4.0.0 with all of them doing the same thing. I was able to make a few dumps of the program and got these 2 errors

ERROR_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application.

ERROR_CODE: (NTSTATUS) 0xc0000374 - A heap has been corrupted.

Steps to Reproduce

I do not know how I would reproduce it since it doesn't happen all the time, Most of the time when trying to mutate an image the program just shuts down but then others it will work fine.

Images

0b1d89f2474e6dac46d1b02baa06150b

We’re going to need a lot more information please.

  • Any compilation details
  • Input image dimensions
  • Text location details, fonts, size

I would recommend creating and sharing a program that replicates the issue.

As a side note.

ImageSharp.Drawing 2.0.1 is not binary compatible with ImageSharp 4-alpha, you should use latest stable 2.1.0 with 3.1.0

You are incorrectly declaring the first drawing action as async.

Creating the same font 3 times is inefficient.

@DigitalEntry Do you have this additional information? Otherwise, we will have to close this issue.

Not at this time. I created another program to try to reproduce the error using the same code in the original program and it worked fine. I'll have to look into it more to see if I can find what's creating this error

@JimBobSquarePants So I did end up fixing the issue, I don't know what was wrong but I figured since I only changed a few things and it stopped working I could maybe try retracing my steps and see if anything I changed somehow made it stop working. I implemented a MemoryCache to cache users a little while back so I switched from MemoryCache to LazyCache just to see what would happen and that fixed my problem. I don't know how but it works fine now.

Hmmm... I wonder whether buffers in your cache were being disposed of prematurely in your application. I'll close this just now but if you have further problems don't hesitate to open a new issue.