https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Bug ID: 1306047 Summary: [Patch] Use posix threads, fix static library Product: Fedora Version: rawhide Component: mingw-glib2 Assignee: erik-fedora@vanpienbroek.nl Reporter: manisandro@gmail.com QA Contact: extras-qa@fedoraproject.org CC: erik-fedora@vanpienbroek.nl, fedora-mingw@lists.fedoraproject.org, fidencio@redhat.com, klember@redhat.com, marcandre.lureau@redhat.com, rjones@redhat.com, t.sailer@alumni.ethz.ch
Created attachment 1122556 --> https://bugzilla.redhat.com/attachment.cgi?id=1122556&action=edit Patch
The attached patch - Sets the threading implementation to posix. Win32 threads seem broken (regardless of whether used with static or dynamically linked glib) - Improves glib-prefer-constructors-over-DllMain.patch to always prefer constructors over DllMain, also handling a second case of DllMain - Adds a missing BR for mingw-pcre
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
--- Comment #1 from Marc-Andre Lureau marcandre.lureau@redhat.com --- (In reply to Sandro Mani from comment #0)
Created attachment 1122556 [details] Patch
The attached patch
- Sets the threading implementation to posix. Win32 threads seem broken
(regardless of whether used with static or dynamically linked glib)
what backs this claim?
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
--- Comment #2 from Sandro Mani manisandro@gmail.com --- Apologies for the scarse info:
Program received signal SIGSEGV, Segmentation faul 0x7c919af2 in ntdll!RtlpWaitForCriticalSection ()
#0 0x7c919af2 in ntdll!RtlpWaitForCriticalSection () from C:\WINDOWS\system32\ntdll.dll #1 0x7c901046 in ntdll!RtlEnterCriticalSection () from C:\WINDOWS\system32\ntdll.dll #2 0x008ae4dc in ?? () #3 0x68837025 in g_private_get_impl ( key=key@entry=0x688497d4 <private_thread_memory>) at ../../glib/gthread-win32.c:342 #4 0x68837b32 in g_private_get_impl (key=0x688497d4 <private_thread_memory>) at ../../glib/gthread-win32.c:340 #5 g_private_get (key=key@entry=0x688497d4 <private_thread_memory>) at ../../glib/gthread-win32.c:386 #6 0x6880edb3 in thread_memory_from_self () at ../../glib/gslice.c:507 #7 g_slice_alloc (mem_size=mem_size@entry=56) at ../../glib/gslice.c:1003 #8 0x687e2c45 in g_hash_table_new_full ( hash_func=hash_func@entry=0x687e3c90 <g_str_hash>, key_equal_func=key_equal_func@entry=0x687e3c60 <g_str_equal>, key_destroy_func=key_destroy_func@entry=0x0, value_destroy_func=value_destroy_func@entry=0x0) at ../../glib/ghash.c:711 #9 0x687e2cf7 in g_hash_table_new (hash_func=0x687e3c90 <g_str_hash>, key_equal_func=0x687e3c60 <g_str_equal>) at ../../glib/ghash.c:674 #10 0x68801fd4 in g_quark_init () at ../../glib/gquark.c:61 #11 0x68847f75 in glib_init () at ../../glib/glib-init.c:243 #12 glib_init_ctor () at ../../glib/glib-init.c:258 #13 0x688424fc in __do_global_ctors ()
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
--- Comment #3 from Marc-Andre Lureau marcandre.lureau@redhat.com --- (In reply to Sandro Mani from comment #2)
Apologies for the scarse info:
That is still very very scarse. Please give more details on what you are running and how to reproduce.
Program received signal SIGSEGV, Segmentation faul 0x7c919af2 in ntdll!RtlpWaitForCriticalSection ()
#0 0x7c919af2 in ntdll!RtlpWaitForCriticalSection () from C:\WINDOWS\system32\ntdll.dll #1 0x7c901046 in ntdll!RtlEnterCriticalSection () from C:\WINDOWS\system32\ntdll.dll #2 0x008ae4dc in ?? () #3 0x68837025 in g_private_get_impl ( key=key@entry=0x688497d4 <private_thread_memory>) at ../../glib/gthread-win32.c:342 #4 0x68837b32 in g_private_get_impl (key=0x688497d4 <private_thread_memory>) at ../../glib/gthread-win32.c:340 #5 g_private_get (key=key@entry=0x688497d4 <private_thread_memory>) at ../../glib/gthread-win32.c:386 #6 0x6880edb3 in thread_memory_from_self () at ../../glib/gslice.c:507 #7 g_slice_alloc (mem_size=mem_size@entry=56) at ../../glib/gslice.c:1003 #8 0x687e2c45 in g_hash_table_new_full ( hash_func=hash_func@entry=0x687e3c90 <g_str_hash>, key_equal_func=key_equal_func@entry=0x687e3c60 <g_str_equal>, key_destroy_func=key_destroy_func@entry=0x0, value_destroy_func=value_destroy_func@entry=0x0) at ../../glib/ghash.c:711 #9 0x687e2cf7 in g_hash_table_new (hash_func=0x687e3c90 <g_str_hash>, key_equal_func=0x687e3c60 <g_str_equal>) at ../../glib/ghash.c:674 #10 0x68801fd4 in g_quark_init () at ../../glib/gquark.c:61 #11 0x68847f75 in glib_init () at ../../glib/glib-init.c:243 #12 glib_init_ctor () at ../../glib/glib-init.c:258 #13 0x688424fc in __do_global_ctors ()
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment|0 |1 #1122556 is| | obsolete| |
--- Comment #4 from Sandro Mani manisandro@gmail.com --- Created attachment 1122599 --> https://bugzilla.redhat.com/attachment.cgi?id=1122599&action=edit Patch
(Oh boy, after a day looking at linking errors and segfaults and got sloppy resp. overexcited when things worked, while I should just have gone to bed. Turns out I screwed things up myself. Sorry for the false alarm.)
Proper patch attached.
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|[Patch] Use posix threads, |[Patch] Fix static library |fix static library |
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
--- Comment #5 from Erik van Pienbroek erik-fedora@vanpienbroek.nl --- (In reply to Sandro Mani from comment #4)
(Oh boy, after a day looking at linking errors and segfaults and got sloppy resp. overexcited when things worked, while I should just have gone to bed. Turns out I screwed things up myself. Sorry for the false alarm.)
Proper patch attached.
It looks you were already half asleep when you uploaded the updated patch. The new patch is one for the mingw-pango package instead of the mingw-glib2 package :)
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment|0 |1 #1122599 is| | obsolete| |
--- Comment #6 from Sandro Mani manisandro@gmail.com --- Created attachment 1122778 --> https://bugzilla.redhat.com/attachment.cgi?id=1122778&action=edit Patch
Yes indeed....
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Erik van Pienbroek erik-fedora@vanpienbroek.nl changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED
--- Comment #7 from Erik van Pienbroek erik-fedora@vanpienbroek.nl --- If I understand the patch correctly there are 3 different changes here: - The glib-prefer-constructors-over-DllMain patch is improved so it also covers a similar issue in the gobject library - A BR: mingw{32,64}-pcre is added so that the external PCRE library is used instead of the bundled one - A BR: mingw{32,64}-winpthreads is added
It appears that the DllMain in gobject was added just recently: https://git.gnome.org/browse/glib/commit/gobject/gtype.c?id=7a29771a743a8b53... and appears to have been done to fix a compatibility issue with MSVC2015/Windows 10 SDK: https://bugzilla.gnome.org/show_bug.cgi?id=752837 For mingw I think the updated patch is correct although it may not work correctly anymore for MSVC..
The change about pcre looks good enough to more, external libraries should be used where possible
The last one shouldn't be necessary. winpthreads should already automatically get pulled in by mingw{32,64}-gcc
In your updated patch the posix threading configure argument seem to have gotten lost. Was this intentional?
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment|0 |1 #1122778 is| | obsolete| |
--- Comment #8 from Sandro Mani manisandro@gmail.com --- Created attachment 1122789 --> https://bugzilla.redhat.com/attachment.cgi?id=1122789&action=edit Patch
The winpthreads was a bad leftover. Removed.
I had mis-diagnosed a crash as being related to win32 threads. Win32 threads are working fine, so yes, it is intentional that I dropped the posix threads configure argument from the patch.
About the glib-prefer-constructors-over-DllMain: the modified code should fall back cleanly to the previous DllMain approach if G_HAS_CONSTRUCTORS is not defined, which should be the case with MSVC. So, unless I'm missing something, nothing should change for MSVC?
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment|0 |1 #1122789 is| | obsolete| |
--- Comment #10 from Sandro Mani manisandro@gmail.com --- Created attachment 1156926 --> https://bugzilla.redhat.com/attachment.cgi?id=1156926&action=edit Patch
Patch rebased.
Would be nice if this could get merged.
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|24 |rawhide
https://bugzilla.redhat.com/show_bug.cgi?id=1306047
--- Comment #11 from Kalev Lember klember@redhat.com --- Can you send this upstream to https://bugzilla.gnome.org/enter_bug.cgi?product=glib , please? And maybe ask nacho to review it on IRC afterwards?
Thanks!