diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-10-25 11:37:26 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-10-25 11:37:26 +0200 |
commit | 5582ec78a20c3de273eef5fe4d6212347482c34f (patch) | |
tree | 11412b33b049be874319598bf64944906e2000d4 | |
parent | a3c606d1cf118ae027f349ea54ff6e8a27224629 (diff) |
glib: Patch from upstream GIT to fix ordering of library ctors
Otherwise we might initialize gobject before glib, causing assertions
and crashes.
https://bugzilla.gnome.org/show_bug.cgi?id=756139
-rw-r--r-- | recipes/build-tools/glib-tools.recipe | 3 | ||||
-rw-r--r-- | recipes/glib.recipe | 3 | ||||
-rw-r--r-- | recipes/glib/0030-Library-ctor-order.patch | 191 |
3 files changed, 195 insertions, 2 deletions
diff --git a/recipes/build-tools/glib-tools.recipe b/recipes/build-tools/glib-tools.recipe index e3877a94..e9eb9292 100644 --- a/recipes/build-tools/glib-tools.recipe +++ b/recipes/build-tools/glib-tools.recipe @@ -20,7 +20,8 @@ class Recipe(recipe.Recipe): "../glib/0009-Unhide-_g_io_modules_ensure_extension_points_registe.patch", '../glib/0014-Don-t-use-AT_FDCWD-on-iOS-for-now.patch', '../glib/0015-Implementation-of-Cocoa-event-loop-integration-in-GM.patch', - '../glib/0020-Include-ntdef.h-for-NTSTATUS.patch' + '../glib/0020-Include-ntdef.h-for-NTSTATUS.patch', + '../glib/0030-Library-ctor-order.patch' ] def prepare(self): diff --git a/recipes/glib.recipe b/recipes/glib.recipe index cbc353ec..74feec57 100644 --- a/recipes/glib.recipe +++ b/recipes/glib.recipe @@ -36,7 +36,8 @@ class Recipe(recipe.Recipe): "glib/0009-Unhide-_g_io_modules_ensure_extension_points_registe.patch", 'glib/0014-Don-t-use-AT_FDCWD-on-iOS-for-now.patch', 'glib/0015-Implementation-of-Cocoa-event-loop-integration-in-GM.patch', - 'glib/0020-Include-ntdef.h-for-NTSTATUS.patch' + 'glib/0020-Include-ntdef.h-for-NTSTATUS.patch', + 'glib/0030-Library-ctor-order.patch' ] files_libs = [ diff --git a/recipes/glib/0030-Library-ctor-order.patch b/recipes/glib/0030-Library-ctor-order.patch new file mode 100644 index 00000000..0a3c2246 --- /dev/null +++ b/recipes/glib/0030-Library-ctor-order.patch @@ -0,0 +1,191 @@ +From 342d3296851dfabd88e9e3909ab45fa16e8139e0 Mon Sep 17 00:00:00 2001 +From: Matthias Clasen <mclasen@redhat.com> +Date: Tue, 6 Oct 2015 19:43:38 -0400 +Subject: Make glib_init safe to call more than once + +This will be needed to fix constructor order for non-GNU libc. + +https://bugzilla.gnome.org/show_bug.cgi?id=756139 +--- + glib/glib-init.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/glib/glib-init.c b/glib/glib-init.c +index e7002e6..405e2ad 100644 +--- a/glib/glib-init.c ++++ b/glib/glib-init.c +@@ -231,6 +231,13 @@ g_debug_init (void) + static void + glib_init (void) + { ++ static gboolean glib_inited; ++ ++ if (glib_inited) ++ return; ++ ++ glib_inited = TRUE; ++ + g_messages_prefixed_init (); + g_debug_init (); + g_quark_init (); +-- +cgit v0.11.2 + +From e0dce8a9ae77cd4430db224c3bb056d9d1882e58 Mon Sep 17 00:00:00 2001 +From: Matthias Clasen <mclasen@redhat.com> +Date: Tue, 6 Oct 2015 19:45:38 -0400 +Subject: Export glib_init via GLIB_PRIVATE_CALL + +This will be used in the next commit to call glib_init from the +gobject constructor, to ensure proper constructor ordering with +non-GNU libc. + +https://bugzilla.gnome.org/show_bug.cgi?id=756139 +--- + glib/glib-init.c | 2 +- + glib/glib-init.h | 1 + + glib/glib-private.c | 3 +++ + glib/glib-private.h | 3 +++ + 4 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/glib/glib-init.c b/glib/glib-init.c +index 405e2ad..24fb627 100644 +--- a/glib/glib-init.c ++++ b/glib/glib-init.c +@@ -228,7 +228,7 @@ g_debug_init (void) + g_mem_gc_friendly = flags & 1; + } + +-static void ++void + glib_init (void) + { + static gboolean glib_inited; +diff --git a/glib/glib-init.h b/glib/glib-init.h +index b56f7e2..e893d55 100644 +--- a/glib/glib-init.h ++++ b/glib/glib-init.h +@@ -25,6 +25,7 @@ + extern GLogLevelFlags g_log_always_fatal; + extern GLogLevelFlags g_log_msg_prefix; + ++void glib_init (void); + void g_quark_init (void); + + #ifdef G_OS_WIN32 +diff --git a/glib/glib-private.c b/glib/glib-private.c +index bbf879f..dd04e58 100644 +--- a/glib/glib-private.c ++++ b/glib/glib-private.c +@@ -20,6 +20,7 @@ + #include "config.h" + + #include "glib-private.h" ++#include "glib-init.h" + + /** + * glib__private__: +@@ -32,6 +33,8 @@ GLibPrivateVTable * + glib__private__ (void) + { + static GLibPrivateVTable table = { ++ glib_init, ++ + g_wakeup_new, + g_wakeup_free, + g_wakeup_get_pollfd, +diff --git a/glib/glib-private.h b/glib/glib-private.h +index 0a28008..198e07f 100644 +--- a/glib/glib-private.h ++++ b/glib/glib-private.h +@@ -61,6 +61,9 @@ typedef struct { + guint flags); + GDir * (* g_dir_new_from_dirp) (gpointer dirp); + ++ /* See glib-init.c */ ++ void (* glib_init) (void); ++ + /* Add other private functions here, initialize them in glib-private.c */ + } GLibPrivateVTable; + +-- +cgit v0.11.2 + +From 8d83aace106b6832629a3e05f49d074a4288c8df Mon Sep 17 00:00:00 2001 +From: Matthias Clasen <mclasen@redhat.com> +Date: Tue, 6 Oct 2015 20:09:08 -0400 +Subject: Call glib_init from the gobject constructor + +We are using quarks in the gobject constructor, among other things, +so we need to ensure that glib is being initialized first. + +https://bugzilla.gnome.org/show_bug.cgi?id=756139 +--- + gobject/gtype.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/gobject/gtype.c b/gobject/gtype.c +index 990002b..be1922c 100644 +--- a/gobject/gtype.c ++++ b/gobject/gtype.c +@@ -31,6 +31,7 @@ + #include "gatomicarray.h" + #include "gobject_trace.h" + ++#include "glib-private.h" + #include "gconstructor.h" + + #ifdef G_ENABLE_DEBUG +@@ -4376,6 +4377,11 @@ gobject_init_ctor (void) + TypeNode *node; + GType type; + ++ /* Ensure GLib is initialized first, see ++ * https://bugzilla.gnome.org/show_bug.cgi?id=756139 ++ */ ++ GLIB_PRIVATE_CALL (glib_init) (); ++ + G_WRITE_LOCK (&type_rw_lock); + + /* setup GObject library wide debugging flags */ +-- +cgit v0.11.2 + +From 99ff9bb5e0ef261e39cb3c67a2d212f6bbeb99e4 Mon Sep 17 00:00:00 2001 +From: Emmanuele Bassi <ebassi@gnome.org> +Date: Thu, 8 Oct 2015 12:32:58 +0100 +Subject: Maintain the struct order when initializing + +Otherwise it'll break every GLIB_PRIVATE_CALL user. +--- + glib/glib-private.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/glib/glib-private.c b/glib/glib-private.c +index dd04e58..3dbf744 100644 +--- a/glib/glib-private.c ++++ b/glib/glib-private.c +@@ -33,8 +33,6 @@ GLibPrivateVTable * + glib__private__ (void) + { + static GLibPrivateVTable table = { +- glib_init, +- + g_wakeup_new, + g_wakeup_free, + g_wakeup_get_pollfd, +@@ -47,7 +45,9 @@ glib__private__ (void) + g_main_context_new_with_next_id, + + g_dir_open_with_errno, +- g_dir_new_from_dirp ++ g_dir_new_from_dirp, ++ ++ glib_init, + }; + + return &table; +-- +cgit v0.11.2 + + |