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

Crash on linux if the system libglib is loaded before Magic.Net gets called #1541

Open
tri-bao opened this issue Feb 5, 2024 · 5 comments
Open

Comments

@tri-bao
Copy link

tri-bao commented Feb 5, 2024

Magick.NET version

Magick.NET-Q16-AnyCPU 12.1.0

Environment (Operating system, version and so on)

.netcore 6 on ubuntu 22.04 docker container

Description

(process:1): GLib-GObject-WARNING **: 03:35:20.257: cannot register existing type 'gchar'
**
GLib-GObject:ERROR:../gobject/gvaluetypes.c:455:_g_value_types_init: assertion failed: (type == G_TYPE_CHAR)
Bail out! GLib-GObject:ERROR:../gobject/gvaluetypes.c:455:_g_value_types_init: assertion failed: (type == G_TYPE_CHAR)

The error is similar to the following tickets:

That happens when, within the same process, the system glib is loaded before Magick.NET

Glib is built with -Bsymbolic-functions linker flag https://docs.gtk.org/glib/building.html#extra-configuration-options Should Magick.Net be built with the same flag to avoid this error?

Steps to Reproduce

Program.cs

using ImageMagick;

using var image = new MagickImage();
LD_PRELOAD=/lib/x86_64-linux-gnu/libgobject-2.0.so.0 dotnet Test.dll

This error happens

@dlemstra
Copy link
Owner

dlemstra commented Feb 5, 2024

Thanks for providing more info but that could have been added to that other issue. Can you create a small project with a Dockerfile that can be used to reproduce this so I can test the build changes?

@tri-bao
Copy link
Author

tri-bao commented Feb 6, 2024

@dlemstra I attached the test project with a Dockerfile in the zip
Test.zip

Build: docker build -t test-magicknet:local .

Run: docker run -it --rm test-magicknet:local

@dlemstra
Copy link
Owner

dlemstra commented Feb 6, 2024

Using that option did not prevent this issue. I don't know what should be done to prevent this. The odd part is that my library is build statically and the other library is loaded dynamically. I don't understand how this even can cause issues. It might help if I disable asserts but it looks like that requires an upgrade of the library and that was a lot of work last time I did this.

@tri-bao
Copy link
Author

tri-bao commented Feb 15, 2024

I don't understand either. This probably gives some hints lovell/sharp-libvips#62

@dlemstra
Copy link
Owner

It doesn't give me any hints. You or someone else will need to come up with a solution for this.

Shiryou added a commit to Shiryou/brut that referenced this issue Oct 13, 2024
GTKSharp (via Eto.Forms) and Magick.NET clash due to an issue with
glib throwing an uncaught error (dlemstra/Magick.NET#1541). Since
C# doesn't support PCX and I haven't found a decent conversion
library to bypass this, we're stuck with the situation until I can
find a workaround. Unclear how this affects MacOS as I don't have a
test environment there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants