1 From e4216dee57f5156e192b2910f13eb855a104cb18 Mon Sep 17 00:00:00 2001
2 From: Natanael Copa <ncopa@alpinelinux.org>
3 Date: Wed, 6 Jul 2016 12:38:40 +0200
4 Subject: [PATCH] gquark: fix initialization with c++ constructors
6 C++ constructors may want create new quarks, but we can not guarantee
7 that the glib library ctor is executed first. Therefore we make sure
8 that quarks are always initialized from g_quark_from_string and
9 g_quark_from_static_string
11 This fixes crashes in glibmm with musl which likely happens on AIX too.
13 https://bugzilla.gnome.org/show_bug.cgi?id=768215
14 https://bugzilla.gnome.org/show_bug.cgi?id=756139#c14
16 glib/gquark.c | 8 ++++++++
17 1 file changed, 8 insertions(+)
19 diff --git a/glib/gquark.c b/glib/gquark.c
20 index 9e51a92..17ecd7f 100644
23 @@ -57,6 +57,11 @@ static gint quark_block_offset = 0;
27 + /* we may be initialized from c++ constructor or the glib ctor, but we
28 + cannot guarantee in what order. So we check if we have been initialized */
29 + if (quark_ht != NULL)
32 g_assert (quark_seq_id == 0);
33 quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
34 quarks = g_new (gchar*, QUARK_BLOCK_SIZE);
35 @@ -179,6 +184,9 @@ quark_from_string (const gchar *string,
39 + if (G_UNLIKELY (quark_ht == NULL))
42 quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string));