dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.27k stars 4.73k forks source link

Tests under: MonoTests.System.Drawing.Imaging.PngCodecTest failed with "System.ArgumentException" #23691

Open ghost opened 7 years ago

ghost commented 7 years ago

Opened on behalf of @Jiayili1

The test MonoTests.System.Drawing.Imaging.PngCodecTest/Bitmap2bitData has failed.

System.ArgumentException : Parameter is not valid.

    Stack Trace:

       at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status) in /root/corefx-1027731/src/System.Drawing.Common/src/System/Drawing/Gdiplus.cs:line 269
   at System.Drawing.Bitmap..ctor(String filename, Boolean useIcm) in /root/corefx-1027731/src/System.Drawing.Common/src/System/Drawing/Bitmap.Unix.cs:line 128
   at System.Drawing.Bitmap..ctor(String filename) in /root/corefx-1027731/src/System.Drawing.Common/src/System/Drawing/Bitmap.Unix.cs:line 105
   at MonoTests.System.Drawing.Imaging.PngCodecTest.Bitmap2bitData() in /root/corefx-1027731/src/System.Drawing.Common/tests/mono/System.Drawing.Imaging/PngCodecTesst.cs:line 343

Build : Master - 20170930.01 (Core Tests) Failing configurations:

Detail: https://mc.dot.net/#/product/netcore/master/source/official~2Fcorefx~2Fmaster~2F/type/test~2Ffunctional~2Fcli~2F/build/20170930.01/workItem/System.Drawing.Common.Tests/analysis/xunit/MonoTests.System.Drawing.Imaging.PngCodecTest~2FBitmap2bitData

danmoseley commented 7 years ago

@mellinoe can you help get the run to 100% green, even if it means disabling tests?

https://mc.dot.net/#/product/netcore/master/source/official~2Fcorefx~2Fmaster~2F/type/test~2Ffunctional~2Fcli~2F/build/20171005.01/workItem/System.Drawing.Common.Tests

stephentoub commented 7 years ago

These three MonoTests.System.Drawing.Imaging.PngCodecTest tests failed again here with the same error: https://mc.dot.net/#/user/Drawaes/pr~2Fjenkins~2Fdotnet~2Fcorefx~2Fmaster~2F/test~2Ffunctional~2Fcli~2F/d983ece4b9431f65637b46081e9bf7c46c02c348/workItem/System.Drawing.Common.Tests

Bitmap2bitData
Bitmap2bitFeatures
Bitmap2bitPixels
stephentoub commented 7 years ago

And a bunch of PngCodecTests failed here with the same error: https://mc.dot.net/#/user/Drawaes/pr~2Fjenkins~2Fdotnet~2Fcorefx~2Fmaster~2F/test~2Ffunctional~2Fcli~2F/7a132a4d2694413bab5762b7af6ef5606c7b8724/workItem/System.Drawing.Common.Tests

Bitmap1bitFeatures
Bitmap1bitPixels
Bitmap2bitData
Bitmap2bitFeatures
Bitmap2bitPixels
Bitmap4bitFeatures
Bitmap4bitPixels
danmoseley commented 7 years ago

@qmfrederik do you have any context on these failures?

BTW, @safern is the new owner of drawing: @mellinoe has left to pursue a new project.

stephentoub commented 7 years ago

And again here: https://mc.dot.net/#/user/stephentoub/pr~2Fjenkins~2Fdotnet~2Fcorefx~2Fmaster~2F/test~2Ffunctional~2Fcli~2F/91ec984d64908b3ab312bef6f6fa599f5ea1cee7/workItem/System.Drawing.Common.Tests

qmfrederik commented 7 years ago

@danmosemsft It's most likely because of an old version of libgdiplus on the CI boxes it's failing on. I've left a note on dotnet/corefx#24545.

xPaw commented 6 years ago

I am actually running into this issue in my software on Linux (https://github.com/SteamDatabase/ValveResourceFormat/issues/94). I'm on debian 9 with libgdiplus 4.2-1+b1 installed.

decherneyge commented 4 years ago

I am running into what I believe is the same issue. Running it on windows it works fine but running it on linux or using WSL it fails. I have attached the gif file that is failing, another failing gif and two other gif file that are working. I looked at the first 6 bytes of the files that are not working and they appear to be valid.

        static void Main(string[] args)
        {

            string imageName = "no_harley.gif";
            string path = $"/{Path.Combine("mnt", "c", "_Source", "LinuxConsoleApp", "LinuxConsoleApp")}";
            string combined = Path.Combine(path, imageName);

            //FromFile fails with a "Parameter is not valid." error
            using (System.Drawing.Image image = System.Drawing.Image.FromFile(combined))
            {

                if (image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Gif.Guid ||
                    image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Jpeg.Guid ||
                    image.RawFormat.Guid == System.Drawing.Imaging.ImageFormat.Png.Guid
                )
                {
                    //Valid
                    Console.WriteLine("File is valid");
                }
                else
                {
                    throw new Exception($"{"Bad File Format"}(raw format guid: {image.RawFormat.Guid})");
                }
            }

        }

//Failing no_harley no_deal with it cat //Working yes_source yes_AdmiredAlarmedHalicore-size_restricted

safern commented 4 years ago

@decherneyge which version of libgdiplus is being used?

decherneyge commented 4 years ago

@decherneyge which version of libgdiplus is being used?

@safern 4.2-2

qmfrederik commented 4 years ago

@decherneyge 4.2 is about 5 years old.

Can you try to use version 6.x of libgdiplus or git master, and see whether the problem reproduces?

decherneyge commented 4 years ago

@qmfrederik mind pointing me in the direction of some instructions on how to install 6.x ? When I use apt-get it says I have the latest (4.2-2)

$ sudo apt-get install -y libgdiplus Reading package lists... Done Building dependency tree Reading state information... Done libgdiplus is already the newest version (4.2-2).

qmfrederik commented 4 years ago

Mono hosts Debian/Ubuntu repositories which have libgdiplus 6.x. You can find instructions on how to add these repositories at https://www.mono-project.com/download/stable/#download-lin .

You don't need to install Mono, only libgdiplus.

Ubuntu 20.04 should be the first Ubuntu version to ship with libgdiplus 6.x.

decherneyge commented 4 years ago

@qmfrederik thanks! I got 6.0.4 installed and the invalid parameter error is now gone. I am running into an out of memory error but as that is different I will investigate separately.

jdavidleo commented 2 years ago

@qmfrederik I'm facing the same issue on a containerized netcore service, I would like to try installing the package v 6.0.4 but I get E: Version '6.0.4' for 'libgdiplus' was not found

my Dockerfile runsfollowing command:

RUN apt-get update \ && apt-get -y install curl \ && apt-get install -y libgdiplus=6.0.4

I'd appreciate your help.

thanks

qmfrederik commented 2 years ago

Are you on Ubuntu Bionic or Debian Bullseye or newer? Older version of Debian/Ubuntu ship with outdated libgdiplus versions. Alternatively, you can fetch libgdiplus from the Mono apt repositories - see https://www.mono-project.com/download/stable/#download-lin

jdavidleo commented 2 years ago

It seems that my base image is using 18.04 (Bionic) so it won't find a newer version than 4.2-2.

I tried but I'm not able to force the apt-get install command to look into mono apt repo, so that it installs libgdiplus=6.0.4

thanks in advance.

jdavidleo commented 2 years ago

So I managed to upgrade to libgdiplus 6.0.4 but the error persists. It happens in the constructor of the Bitmap object, when I pass a string referencing the location of a .bmp file, I tried with a different .bmp and it works, I also made sure that the first .bmp exists.

apart from that I have no idea what else to try.

I appreciate your insights. thanks.