mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
333 stars 171 forks source link

Error (sudden death) for System.Drawing.Image.FromStream in docker for almost empty images #657

Open safern opened 4 years ago

safern commented 4 years ago

Copied over from: https://github.com/dotnet/runtime/issues/31276

.Net Core version affected: 2.2

I can reproduce the problem in my development environment; please see the following repository to have a working example:

https://github.com/LeonSebastianCoimbra/ImageFromStreamError

The tools used are:

For the details of the execution, please see the Dockerfile on the project; as summary, i can say that it is a Linux Alpine (latest official microsoft/dotnet2.2-aspnetcore-runtime from dockerhub) plus the latest available version of libgdiplus.

The problem arise when we try to open a particular image with System.Drawing.Image.FromStream: if the image is nearly empty (see the example posted) a native exception is executed and the program end abruptly, without even giving the chance to manage the error. The same image opened with System.Drawing.Image.FromFile works fine (except that it is locked by the GDI+ engine).

To reproduce the problem:

You'll see that the fist two attempts to open the file with "FromFile" will work, while the last one will fails.

cc: @akoeplinger @LeonSebastianCoimbra