Bug 2334180 - Cross compilation and distributing mingw64 gtk2-based programs crash
Summary: Cross compilation and distributing mingw64 gtk2-based programs crash
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mingw-gtk2
Version: 41
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kalev Lember
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-12-26 10:28 UTC by Dov Grobgeld
Modified: 2025-01-09 02:02 UTC (History)
4 users (show)

Fixed In Version: mingw-gtk2-2.24.33-14.fc41
Clone Of:
Environment:
Last Closed: 2025-01-09 02:02:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dov Grobgeld 2024-12-26 10:28:57 UTC
Description of problem:

Crosscompiling and distributing gtk2 based program with the mingw64-gtk2 package of head fedora crash when installed and run under windows

Version-Release number of selected component (if applicable):
```
$ rpm -q -i mingw64-gtk2
Name        : mingw64-gtk2
Version     : 2.24.33
Release     : 12.fc41
Architecture: noarch
Install Date: Tue Dec 17 22:03:24 2024
Group       : Unspecified
Size        : 31958213
License     : LGPLv2+
Signature   : RSA/SHA256, Wed Jul 24 16:36:23 2024, Key ID d0622462e99d6ad1
Source RPM  : mingw-gtk2-2.24.33-12.fc41.src.rpm
Build Date  : Wed Jul 24 16:30:36 2024
Build Host  : buildhw-x86-15.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.gtk.org
Bug URL     : https://bugz.fedoraproject.org/mingw-gtk2
Summary     : MinGW Windows Gtk2 library
Description :
MinGW Windows Gtk2 library.
```
How reproducible:

Every time

Steps to Reproduce:
1.Create the following gtk2 program `gtk-hello-world.c`:
```C
#include <stdlib.h>
#include <gtk/gtk.h>

int main(int argc, char **argv)
{
  gtk_init(&argc, &argv);
  GtkWidget *w_mw = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect(w_mw,"destroy",gtk_main_quit, NULL);
  GtkWidget *w_label = gtk_label_new(NULL);

  gtk_label_set_markup(GTK_LABEL(w_label), "Hello Gtk on Windows");

  gtk_container_add(GTK_CONTAINER(w_mw), w_label);
  gtk_widget_show_all(w_mw);
  gtk_main();

  exit(0);
}
```
2. Compile and create a binary distribution of this program for windows through the following Makefile:
```make
ARCH = x86_64-w64-mingw32
CC = $(ARCH)-gcc
FLAGS = `env PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig pkg-config --cflags --libs gtk+-2.0`
TARGET = gtk-hello-world.exe
SRC = gtk-hello-world.c

all: $(TARGET) distribution

$(TARGET): $(SRC) 
	$(CC) -o $(TARGET) $(SRC) $(FLAGS) 

clean:
	rm -f $(TARGET)

distribution:
	mkdir -p dist/bin
	cp $(TARGET) dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/iconv.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libatk-1.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libbz2-1.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libcairo-2.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libcairo-gobject-2.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libcroco-0.6-3.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libffi-8.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libfontconfig-1.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libfreetype-6.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libfribidi-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgcc_s_seh-1.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgdk-win32-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgdk_pixbuf-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgio-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libglib-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgmodule-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgobject-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgthread-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libgtk-win32-2.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libharfbuzz-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libharfbuzz-icu-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libharfbuzz-subset-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libintl-8.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libjpeg-62.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpango-1.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpangocairo-1.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpangoft2-1.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpangowin32-1.0-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpcre-1.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpcre2-8-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpixman-1-0.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libpng16-16.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libstdc++-6.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libtiff-5.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libwinpthread-1.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libxml2-2.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/libxml2-2.dll dist/bin
	cp /usr/$(ARCH)/sys-root/mingw/bin/zlib1.dll dist/bin
	mkdir -p dist/etc
	rsync -a /usr/$(ARCH)/sys-root/mingw/etc/gtk-2.0 dist/etc
	rsync -a /usr/$(ARCH)/sys-root/mingw/etc/pango dist/etc
	mkdir -p dist/share
	rsync -a /usr/$(ARCH)/sys-root/mingw/share/gtk-2.0 dist/share
	rsync -a /usr/$(ARCH)/sys-root/mingw/share/themes dist/share
	mkdir -p dist/lib
	rsync -a /usr/$(ARCH)/sys-root/mingw/lib/gtk-2.0 dist/share
	rm dist.zip && zip -r dist.zip dist

```
3. Copy the resulting `dist.zip` file to a Windows 10 computer and unzip it, e.g. to c:\Temp
4. cd to dist\bin 
5. Run 'gtk-hello-world`

Actual results:

The program crashes.

Expected results:

The program should show the gtk interface.

Additional info:

Running the program in gdb under windows show the following stack trace of the crash:

```
(gdb) run
Starting program: /c/Temp/dist/bin/gtk-hello-world
[New Thread 2008.0x12f4]
[New Thread 2008.0x17dc]
[New Thread 2008.0xde0]

(gtk-hello-world.exe:2008): Gtk-WARNING **: 10:19:49.728: Unable to locate theme engine in module_pa
th: "wimp",
gdb: unknown target exception 0xc0000409 at 0x7ff913e91208

Thread 1 received signal ?, Unknown signal.
0x00007ff913e91208 in ucrtbase!_invoke_watson () from /c/Windows/System32/ucrtbase.dll
(gdb) where
#0  0x00007ff913e91208 in ucrtbase!_invoke_watson () from /c/Windows/System32/ucrtbase.dll
#1  0x00007ff913e424b1 in ucrtbase!_invalid_parameter_noinfo ()
   from /c/Windows/System32/ucrtbase.dll
#2  0x00007ff913e42379 in ucrtbase!_invalid_parameter_noinfo ()
   from /c/Windows/System32/ucrtbase.dll
#3  0x00007ff913e7406b in ucrtbase!.intrinsic_setjmpex () from /c/Windows/System32/ucrtbase.dll
#4  0x00007ff8de955c9d in gtk_rc_context_parse_one_file ()
   from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#5  0x00007ff8de955e71 in gtk_rc_context_parse_file () from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#6  0x00007ff8de9560b7 in gtk_rc_parse_named () from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#7  0x00007ff8de9563f3 in gtk_rc_reparse_all_for_settings ()
   from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#8  0x00007ff8de973b23 in gtk_settings_get_for_screen ()
   from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#9  0x00007ff8de98a27e in gtk_style_init () from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#10 0x00007ff8ff82afac in g_type_create_instance () from /c/Temp/dist/bin/libgobject-2.0-0.dll
#11 0x00007ff8ff80e581 in g_object_new_internal.part () from /c/Temp/dist/bin/libgobject-2.0-0.dll
#12 0x00007ff8ff80ff7e in g_object_new_with_properties ()
   from /c/Temp/dist/bin/libgobject-2.0-0.dll
#13 0x00007ff8ff810d4b in g_object_new () from /c/Temp/dist/bin/libgobject-2.0-0.dll
#14 0x00007ff8dea2cf75 in gtk_widget_init () from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#15 0x00007ff8ff82af74 in g_type_create_instance () from /c/Temp/dist/bin/libgobject-2.0-0.dll
#16 0x00007ff8ff80e581 in g_object_new_internal.part () from /c/Temp/dist/bin/libgobject-2.0-0.dll
#17 0x00007ff8ff80ff7e in g_object_new_with_properties ()
   from /c/Temp/dist/bin/libgobject-2.0-0.dll
#18 0x00007ff8ff810d4b in g_object_new () from /c/Temp/dist/bin/libgobject-2.0-0.dll
--Type <RET> for more, q to quit, c to continue without paging--
#19 0x00007ff8dea3ce0f in gtk_window_new () from /c/Temp/dist/bin/libgtk-win32-2.0-0.dll
#20 0x00007ff667fe1493 in main ()
(
```

I have found two ways to work around this crash:

1. Remove dist/share/themes/MS-Windows/gtk-2.0/gtkrc from the distribution
2. Override the following two files with the corresponding files from fedora32 (though I'm not sure that was their origin, however I'm providing their md5 sum below):

616f5a17988aa7e86585842c3aedcfd5  libgdk-win32-2.0-0.dll
07185e65d8cc6a94b379041add90e36f  libgtk-win32-2.0-0.dll

Comment 1 Fedora Update System 2024-12-31 11:52:55 UTC
FEDORA-2024-8e9f6026f2 (mingw-gtk2-2.24.33-14.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-8e9f6026f2

Comment 2 Sandro Mani 2024-12-31 11:53:25 UTC
Hi, please check whether mingw-gtk2-2.24.33-14.fc41 fixes this.

Comment 3 Dov Grobgeld 2024-12-31 21:30:47 UTC
It's ok now. Thanks!

Comment 4 Fedora Update System 2025-01-01 03:11:13 UTC
FEDORA-2024-8e9f6026f2 has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-8e9f6026f2`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-8e9f6026f2

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2025-01-09 02:02:43 UTC
FEDORA-2024-8e9f6026f2 (mingw-gtk2-2.24.33-14.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.