Bug 76799

Summary: segfault or sigill late - wrong max glib version prevent
Product: realmd Reporter: Alban Browaeys <prahal>
Component: GeneralAssignee: Stef Walter <stefw>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: realmd requires glib max 2.38 minimum

Description Alban Browaeys 2014-03-30 16:47:15 UTC
Created attachment 96622 [details] [review]
realmd requires glib max 2.38  minimum

It turns out that when glib max version is 2.36 in configure.ac as realmd has, build complains but does not error out. But the binary ends up not allocating the parent_instance private structure. Valgrind complains so at least and switching from GLIB_MAX=GLIB_VERSION_2_36 to GLIB_MAX=GLIB_VERSION_2_38 in configture.ac makes it quiet and also phase out the various segfault and sigill I had (on x86 , x86_64 and armhf) .

Follows the relevant part of the build log, the first valgrind lines of output and an extract of the gdb session that shows the parent_instance GDBusInterfaceSkeleton GMutex internals field __kind with the same address as the object itself - RealmDbusServiceSkeleton -  context field. Then in realm_dbus_service_skeleton_init when context is assigned, the value of the parent_instance lock is corrupted (equals the address of the context instead of 3).


Build:

make[2] : on entre dans le répertoire « /home/prahal/Projects/Devel/Gnome/jhbuild/build/realmd/dbus »
  CC     librealm_dbus_a-realm-dbus-generated.o
realm-dbus-generated.c: In function ‘realm_dbus_provider_proxy_get_type’:
realm-dbus-generated.c:732:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusProviderProxy, realm_dbus_provider_proxy, G_TYPE_DBUS_PROXY,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_provider_skeleton_get_type’:
realm-dbus-generated.c:1363:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusProviderSkeleton, realm_dbus_provider_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_service_proxy_get_type’:
realm-dbus-generated.c:2292:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusServiceProxy, realm_dbus_service_proxy, G_TYPE_DBUS_PROXY,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_service_skeleton_get_type’:
realm-dbus-generated.c:2838:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusServiceSkeleton, realm_dbus_service_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_realm_proxy_get_type’:
realm-dbus-generated.c:4134:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusRealmProxy, realm_dbus_realm_proxy, G_TYPE_DBUS_PROXY,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_realm_skeleton_get_type’:
realm-dbus-generated.c:4879:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusRealmSkeleton, realm_dbus_realm_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_kerberos_proxy_get_type’:
realm-dbus-generated.c:5464:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusKerberosProxy, realm_dbus_kerberos_proxy, G_TYPE_DBUS_PROXY,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_kerberos_skeleton_get_type’:
realm-dbus-generated.c:6079:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusKerberosSkeleton, realm_dbus_kerberos_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_kerberos_membership_proxy_get_type’:
realm-dbus-generated.c:7035:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusKerberosMembershipProxy, realm_dbus_kerberos_membership_proxy, G_TYPE_DBUS_PROXY,
 ^
realm-dbus-generated.c: In function ‘realm_dbus_kerberos_membership_skeleton_get_type’:
realm-dbus-generated.c:7662:1: attention : ‘g_type_add_instance_private’ is deprecated (declared at /opt/gnome/include/glib-2.0/gobject/gtype.h:1286): Not available before 2.38 [-Wdeprecated-declarations]
 G_DEFINE_TYPE_WITH_CODE (RealmDbusKerberosMembershipSkeleton, realm_dbus_kerberos_membership_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
 ^
  AR     librealm-dbus.a




valgrind :
==29821== Invalid write of size 8
==29821==    at 0x564FA6F: g_mutex_init (gthread-posix.c:168)
==29821==    by 0x432D2F: realm_dbus_service_skeleton_init (realm-dbus-generated.c:2878)
==29821==    by 0x50C7C0A: g_type_create_instance (gtype.c:1868)
==29821==    by 0x50AD5DD: g_object_new_internal (gobject.c:1724)
==29821==    by 0x50ADAB7: g_object_newv (gobject.c:1868)
==29821==    by 0x50AD1BC: g_object_new (gobject.c:1568)
==29821==    by 0x432FE0: realm_dbus_service_skeleton_new (realm-dbus-generated.c:2928)
==29821==    by 0x41A60C: realm_invocation_initialize (realm-invocation.c:401)
==29821==    by 0x40F647: initialize_service (realm-daemon.c:174)
==29821==    by 0x40F930: on_bus_get_connection (realm-daemon.c:243)
==29821==    by 0x5BAAF83: g_simple_async_result_complete (gsimpleasyncresult.c:763)
==29821==    by 0x5BAAFCF: complete_in_idle_cb (gsimpleasyncresult.c:775)
==29821==  Address 0x9b2aa48 is not stack'd, malloc'd or (recently) free'd

realm-dbus-generated.c:
I  added:
GDBusInterfaceSkeleton *interface = &skeleton->parent_instance;
in static void
realm_dbus_service_skeleton_init (RealmDbusServiceSkeleton *skeleton)
for ease of debugging. In this function context assignment overwrites the
parent_instance->priv->lock->p->__data->__kind (ie the pthread_mutex_t items that made up the GMutex.

(gdb) p &((pthread_mutex_t*)interface->priv->lock->p)->__data->__kind
$10 = (int *) 0x666800
(gdb) p skeleton->priv->context
$11 = (GMainContext *) 0x3
(gdb) p &skeleton->priv->context
$12 = (GMainContext **) 0x666800

Later on various issues appears : mostly sigill and segfaults.
Comment 1 Stef Walter 2014-03-31 05:58:51 UTC
This is an ugly bug in gdbus-codegen. The GLib distributed by your distro is broken:

https://bugzilla.gnome.org/show_bug.cgi?id=710133
Comment 2 Stef Walter 2016-04-14 08:01:56 UTC
This should be fixed in packaged versions of GLib.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.