D-Bus daemon big and little endian issue

Bart Vanherck bavh.best at gmail.com
Mon May 30 05:45:38 PDT 2011


We experience some problems with dbus. We have a java application, when the
application enters the dbus, the dbus-monitor quits. First we were thinking
that there were problems in the java bindings, but it is not.  I also
noticed the following post on this mailinglist a few years ago:
http://web.archiveorange.com/archive/v/2mxmYltly6ixKYVh5MJe that describes
the same problem as we have, but as we are developing on the latest debian
stable 6.0 the issue seems not to be solved, maybe because it is rarely
seen.

I start first the dbus daemon in a private session
then listen with dbus-monitor
as 3th launch the java application.

This causes the dbus-monitor to exit because of the lenghts in the fields
are not corrrect.
The java application sends following data to the dbus layer:

RequestName to dbus-daemon
0042  42 01 00 01 00 00  00 18 00 00 00 02 00 00   j.B..... ........
0050  00 80 01 01 6f 00 00 00  00 15 2f 6f 72 67 2f 66   ....o... ../org/f
0060  72 65 65 64 65 73 6b 74  6f 70 2f 44 42 75 73 00   reedeskt op/DBus.
0070  00 00 06 01 73 00 00 00  00 14 6f 72 67 2e 66 72   ....s... ..org.fr
0080  65 65 64 65 73 6b 74 6f  70 2e 44 42 75 73 00 00   eedeskto p.DBus..
0090  00 00 02 01 73 00 00 00  00 14 6f 72 67 2e 66 72   ....s... ..org.fr
00a0  65 65 64 65 73 6b 74 6f  70 2e 44 42 75 73 00 00   eedeskto p.DBus..
00b0  00 00 03 01 73 00 00 00  00 0b 52 65 71 75 65 73   ....s... ..Reques
00c0  74 4e 61 6d 65 00 00 00  00 00 08 01 67 00 02 73   tName... ....g..s
00d0  75 00 00 00 00 0c 74 65  73 74 2e 73 65 72 76 69   u.....te st.servi
00e0  63 65 00 00 00 00 00 00  00 06                     ce...... ..


As you can see this is big endian

The dbus-daemon sends the same message to the monitor (who is in little
endian format)

0042  42 01 00 01 18 00  00 00 02 00 00 00 8e 00   j.B..... ........
0050  00 00 01 01 6f 00 15 00  00 00 2f 6f 72 67 2f 66   ....o... ../org/f
0060  72 65 65 64 65 73 6b 74  6f 70 2f 44 42 75 73 00   reedeskt op/DBus.
0070  00 00 06 01 73 00 14 00  00 00 6f 72 67 2e 66 72   ....s... ..org.fr
0080  65 65 64 65 73 6b 74 6f  70 2e 44 42 75 73 00 00   eedeskto p.DBus..
0090  00 00 02 01 73 00 14 00  00 00 6f 72 67 2e 66 72   ....s... ..org.fr
00a0  65 65 64 65 73 6b 74 6f  70 2e 44 42 75 73 00 00   eedeskto p.DBus..
00b0  00 00 03 01 73 00 0b 00  00 00 52 65 71 75 65 73   ....s... ..Reques
00c0  74 4e 61 6d 65 00 00 00  00 00 08 01 67 00 02 73   tName... ....g..s
00d0  75 00 07 01 73 00 05 00  00 00 3a 31 2e 33 35 00   u...s... ..:1.35.
00e0  00 00 0c 00 00 00 74 65  73 74 2e 73 65 72 76 69   ......te st.servi
00f0  63 65 00 00 00 00 06 00  00 00                     ce...... ..


The problem is that the lengths are in little endian but the field indicates
big endian.

This happens only with some method calls, for example the Hello call does
not have the problem. We can reproduce this 100%.

The java application we use has the following code:

import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;


public class DbusTester {

        DBusConnection conn;

        public DbusTester(String dbusAddress) throws DBusException {
                conn = DBusConnection.getConnection(dbusAddress);
        }

        public void execute() throws Exception {
                conn.requestBusName("test.service");
                // stay alive for a while
                Thread.sleep(5000);
        }

        public void exit() {
                if (conn != null) conn.disconnect();
        }

        public static void main(String[] args) {
                DbusTester dbusTest = null;
                try {
                        if (args.length == 0) {
                                System.out.println("usage: DbusTest
<dbusAddress>");
                        }
                        dbusTest = new DbusTester(args[0]);
                        dbusTest.execute();
                }
                catch (Exception e) {
                        e.printStackTrace();
                }
                finally {
                        if (dbusTest != null) dbusTest.exit();
                }
        }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20110530/d3c8c099/attachment.htm>


More information about the dbus mailing list