Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log version of libgdiplus to the console in System.Drawing.Common.Tests #29625

Closed
safern opened this issue May 21, 2019 · 6 comments
Closed

Log version of libgdiplus to the console in System.Drawing.Common.Tests #29625

safern opened this issue May 21, 2019 · 6 comments
Labels
area-System.Drawing test-enhancement Improvements of test source code
Milestone

Comments

@safern
Copy link
Member

safern commented May 21, 2019

We've hit various situations that we wanted to know the version of libgdiplus that was used for a test run. So logging it to the console on startup of the System.Drawing.Common.Tests when running in a non-Windows environment would be really useful.

Maybe void WINGDIPAPI GdiplusShutdown (ULONG_PTR token); can be used to do so.

We do that already in InteropServices tests: https://github.com/dotnet/corefx/blob/008d21c47c22b5757e09f6c3d346998004a0f985/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs#L16

cc: @danmosemsft @filipnavara

@am11
Copy link
Member

am11 commented May 21, 2019

To get the version, the portable approaches seem to be returning 0 for libgdiplus on Ubuntu:

ldconfig -v 2> /dev/null | grep libgdiplus
# => libgdiplus.so.0 -> libgdiplus.so.0.0.0


readelf -d  `find / -name libgdiplus.so 2> /dev/null` | grep SONAME
# => 0x000000000000000e (SONAME)             Library soname: [libgdiplus.so.0]

(usually these are enough for libs that are using proper semantic versioning)

For Debian and derived OSes, perhaps something like this would do the job:

using System;
using System.Diagnostics;

public class Test
{
    public static void Main()
    {
        try
        {
            using(var process = Process.Start(new ProcessStartInfo
            {
                FileName = "dpkg-query",
                Arguments = "--showformat '${Version}' --show libgdiplus",
                RedirectStandardOutput = true,
                UseShellExecute = false
            }))
            {
                process.WaitForExit();
                Console.WriteLine(process.StandardOutput.ReadToEnd());
            }
        }
        catch(Exception ex)
        {
            Console.WriteLine("Unable to determine libgdiplus version using `dpkg-query`. exception: {0}", ex);
        }
    }
}

prints 4.2-2.

@danmoseley
Copy link
Member

Does this not work?

/* libgdiplus-specific API, useful for quirking buggy behavior in older versions */
WINGDIPAPI char* GetLibgdiplusVersion ();

@am11
Copy link
Member

am11 commented May 21, 2019

readelf -Ws /usr/lib/libgdiplus.so | grep Version => {nothing}
Seems like it was added in Sep 2017: mono/libgdiplus@43f33e8, and hasn't made it to "Ubuntu 18.04.2 LTS" packages.

If we compile libgdiplus, then the version API shows up:

# ubuntu
apt install -y libtool libjpeg-dev libtiff-dev libcairo2-dev libglib2.0-dev git autoconf

git clone https://github.com/mono/libgdiplus --single-branch --branch master --depth 1
cd libgdiplus
./autogen.sh
make install

readelf -Ws src/.libs/libgdiplus.so.0 | grep Version
   252: 0000000000016b90    12 FUNC    GLOBAL DEFAULT   12 GetLibgdiplusVersion
  1257: 0000000000016b90    12 FUNC    GLOBAL DEFAULT   12 GetLibgdiplusVersion

@danmoseley
Copy link
Member

Ah, I didn't notice it wasn't there yet. Yeah I guess we would have to do different things on different systems 😞

@ViktorHofer
Copy link
Member

@am11 do you want to give it a try and submit a PR to add the libgdiplus version logging? This would really help us diagnose a few crashes.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the Future milestone Feb 1, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label Jul 8, 2020
@JeremyKuhne
Copy link
Member

Closing this issue as System.Drawing.Common is only supported on Windows now.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Drawing test-enhancement Improvements of test source code
Projects
None yet
Development

No branches or pull requests

8 participants