After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 652197 - Improper handling of double values in GDBusMessage
Improper handling of double values in GDBusMessage
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
2.28.x
Other Linux
: Normal critical
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-06-09 14:37 UTC by Matthew Bucknall
Modified: 2011-06-09 16:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix double/guint64 alignment issue in gdbusmessage.c (1.45 KB, patch)
2011-06-09 14:37 UTC, Matthew Bucknall
reviewed Details | Review

Description Matthew Bucknall 2011-06-09 14:37:33 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.
Comment 1 David Zeuthen (not reading bugmail) 2011-06-09 15:08:54 UTC
I agree there's a problem here. But I'd prefer using a union for this - it seems like a nicer fix.
Comment 2 Matthew Bucknall 2011-06-09 15:47:20 UTC
Fair enough. Please provide a patch and I will endeavor to confirm that it works.
Comment 3 Matthew Bucknall 2011-06-09 15:48:19 UTC
Fair enough. Please provide a patch and I will endeavor to confirm that it works.
Comment 4 David Zeuthen (not reading bugmail) 2011-06-09 16:05:07 UTC
(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!