-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
Crash when creating MagickImage in a project using GtkSharp on Linux #1126
Comments
It looks like this warning is raised inside GtkSharp. I checked the code that is statically linked inside Magick.NET the error message should be this: I don't know why this happening and I also don't know how I can debug this. |
I gave a poke around myself. I suppose it'd just start with stepping through and figuring out what C function is being called by .NET right before this happens, and look through what's going on there. I put this to the side, as Linux support is not immediately important to what I am doing, but if you can't think of anything, I may give a deeper look if I can. Certainly if two-language debugging gets involved, it would be messy. |
I'm still looking into this on and off. It's quite bizarre, but right now I have reason to suspect Magick.Native, as it seems to include glib 2.64.3 I can't seem to find where glib is currently being used by Magick.NET, and I wasn't able to find any usage upstream in ImageMagick. I tried to import Magick.NET's source into my project, just to debug, but some preprocessor macros influenced by platform/configuration seem to be nonfunctional in my Linux environment. Expect everything I said to be wrong, but it might at least provide a few clues as to what is going on here. |
It does actually seem that Magick.NET is capable of running in a separate thread to GtkSharp without crashing. So a potential workaround is to separate every single call to Magick.NET into a task. This has to be call-only, however, and can't even reference a single context that GtkSharp is active in (even if not accessing any GtkSharp values/functions). I'd say I'm more confident in my assertion that it's two incompatible, statically linked versions of glib that are trying to load in the same memory space and clashing with each other. The only possible fix I can think of for Linux is to dynamically link to system libraries, but this would also require code change to GtkSharp to do the same. I still am not sure why this doesn't impact NT, but it's probably just down to how native interop works in .NET on that platform. |
Description
This issue affects Linux specifically, Windows is not impacted.
This issue also is in regard to working with another library with C/C++ bindings, GtkSharp. I opened the issue in this repository, as I believe the problem is more likely in Magick.NET than in GtkSharp, as all GtkSharp objects create fine.
In a project utilizing GtkSharp (the modern one, not mono's), creating a MagickImage (from a file or even an empty one) will result in a warning by GLib-GObject and then kill the program after an assertion fails later.
Steps to Reproduce
Create a .NET 6 console project, and add packages Magick.NET-Q8-AnyCPU and GtkSharp (versions used below)
Place the following in Program.cs, and then dotnet run
The following error will be produced, and then the application will die
System Configuration
Functions on Windows 10 when running the exact same code/project
The text was updated successfully, but these errors were encountered: