DBus/GLib Bindings - dbus_g_method_get_sender segfaults

Chris Shields code at csvs.co.uk
Mon Oct 15 06:44:38 PDT 2007

I've been learning the DBus GLib bindings by adapting some sample code from
Ross Burton. I'm trying to get the name of the message sender, so I've
changed the method to asynchronous. However, I'm having problems with the
dbus_g_method_get_sender method, or any other method which uses the
DBusGMethodInvocation *context parameter (see below):

/* The echo method */
static void
echo_echo (Echo *echo, char *string, DBusGMethodInvocation *context)
  printf("String = %s\n", string);
  char *sender = dbus_g_method_get_sender(context);   <--- Segfaults here
  printf("Sender = %s\n", sender);

The XML used by the binding tool is:

<node name="/com/openedhand/DBus/Tests/Echo">
	<interface name="com.openedhand.DBus.Tests.Echo">
		<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="echo" /> 
		<method name="Echo">
			<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="echo_echo" /> 
			<annotation name="org.freedesktop.Dbus.GLib.Async"
value="" /> 
			<arg name="test" type="s" direction="in" /> 

The full code (including a makefile) is available at
http://code.csvs.co.uk/dbus/ - there's not much too it, I've only changed a
few bits from Ross' sample code.

I'm using v1.0.2-1 of DBus and 0.73-1 of dbus-glib.

Let me know if I need to provide any more information, I'm only just getting
started with DBus.

Any help on this would be really appreciated, I've spent a day trying to
debug this so far with no luck!



C Shields
code at csvs.co.uk

More information about the dbus mailing list