Bug 1306047

Summary: [Patch] Fix static library
Product: [Fedora] Fedora Reporter: Sandro Mani <manisandro>
Component: mingw-glib2Assignee: Kalev Lember <klember>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: erik-fedora, fedora-mingw, fedora, fidencio, klember, marcandre.lureau, rjones, springermac
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-12 11:06:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Sandro Mani 2016-02-09 23:20:14 UTC
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)
- 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

Comment 1 Marc-Andre Lureau 2016-02-09 23:37:30 UTC
(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?

Comment 2 Sandro Mani 2016-02-09 23:40:15 UTC
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 ()

Comment 3 Marc-Andre Lureau 2016-02-09 23:46:59 UTC
(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 ()

Comment 4 Sandro Mani 2016-02-10 01:02:02 UTC
Created attachment 1122599 [details]
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.

Comment 5 Erik van Pienbroek 2016-02-10 11:20:19 UTC
(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 :)

Comment 6 Sandro Mani 2016-02-10 12:15:33 UTC
Created attachment 1122778 [details]
Patch

Yes indeed....

Comment 7 Erik van Pienbroek 2016-02-10 13:27:41 UTC
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=7a29771a743a8b5337af5f3fcd1fbfdfdc5d1b81 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?

Comment 8 Sandro Mani 2016-02-10 13:39:50 UTC
Created attachment 1122789 [details]
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?

Comment 9 Jan Kurik 2016-02-24 14:27:48 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase

Comment 10 Sandro Mani 2016-05-12 21:52:02 UTC
Created attachment 1156926 [details]
Patch

Patch rebased.

Would be nice if this could get merged.

Comment 11 Kalev Lember 2016-05-13 07:07:55 UTC
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!

Comment 12 Jan Kurik 2016-07-26 04:16:10 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.

Comment 13 Fedora Admin XMLRPC Client 2017-01-05 20:54:27 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 14 Fedora Admin XMLRPC Client 2017-01-05 21:08:16 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 15 Fedora End Of Life 2017-11-16 18:53:15 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 16 Fedora End Of Life 2017-12-12 11:06:23 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.