GNOME Bugzilla – Bug 652197
Improper handling of double values in GDBusMessage
Last modified: 2011-06-09 16:05:07 UTC
Created attachment 189552 [details] [review] Patch to fix double/guint64 alignment issue in gdbusmessage.c GDBusMessage does not serialize/deserialize double values correctly on platforms with strict alignment constraints (in my particular case, ARM926EJ-S). For example: GDBus-debug:Message: >>>> SENT D-Bus message (56 bytes) Type: method-return Flags: no-reply-expected Version: 0 Serial: 34 Headers: reply-serial -> uint32 2 destination -> ':1.4' signature -> signature 'd' Body: (23.49853515625,) UNIX File Descriptors: (none) 0000: 6c 02 01 01 08 00 00 00 22 00 00 00 1d 00 00 00 l......."....... 0010: 08 01 67 00 01 64 00 00 05 01 75 00 02 00 00 00 ..g..d....u..... 0020: 06 01 73 00 04 00 00 00 3a 31 2e 34 00 00 00 00 ..s.....:1.4.... 0030: 00 00 00 00 04 69 42 40 Note that the body of the message is supposed to contain a double with a value of 23.49853515625 but is presented in the message's payload as '00 00 00 00 04 69 42 40' which equates to 36.8204. See patch for offending code and solution. In summary, do not cast and de-reference a pointer from one type to another type with potentially different alignment constraints.
I agree there's a problem here. But I'd prefer using a union for this - it seems like a nicer fix.
Fair enough. Please provide a patch and I will endeavor to confirm that it works.
(In reply to comment #3) > Fair enough. Please provide a patch and I will endeavor to confirm that it > works. Sure thing, see http://git.gnome.org/browse/glib/commit/?id=13b93f0c48a39c3502f55e011362bcb4d40a5a7d Please reopen the bug if this doesn't work. And thanks for reporting the bug and testing GLib on ARM!