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 392853 - gnome-settings-daemon unaligned accesses
gnome-settings-daemon unaligned accesses
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: [obsolete] settings-daemon
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-01-04 19:44 UTC by Ray Strode [halfline]
Modified: 2007-02-23 22:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This should fix things (477 bytes, patch)
2007-01-04 19:46 UTC, Ray Strode [halfline]
none Details | Review

Description Ray Strode [halfline] 2007-01-04 19:44:14 UTC
(from https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=215027)

On the ia64 architecture, people are seeing unaligned access messages in their syslogs for gnome-settings-daemon.

Program received signal SIGBUS, Bus error.

Thread 2305843009259911824 (LWP 5158)

  • #0 _XData32
    at XlibInt.c line 3056
  • #1 XChangeProperty
    at ChProp.c line 85
  • #2 xkl_engine_set_switch_to_secondary_group
    at xklavier.c line 71
  • #3 xkl_engine_constructor
    at xklavier.c line 627
  • #4 g_object_newv
    from /lib/libgobject-2.0.so.0
  • #5 g_object_new_valist
    from /lib/libgobject-2.0.so.0
  • #6 g_object_new
    from /lib/libgobject-2.0.so.0
  • #7 xkl_engine_get_instance
    at xklavier.c line 194
  • #8 ??
  • #2 xkl_engine_set_switch_to_secondary_group
    at xklavier.c line 71

This is actually a libxklavier bug, but I don't see a component for that in freedesktop bugzilla, so i'm abusing control-center's bugzilla a bit.
Comment 1 Ray Strode [halfline] 2007-01-04 19:46:43 UTC
Created attachment 79405 [details] [review]
This should fix things

XChangeProperty has unintuitive semantics.  We need to make sure it gets passed the address of a long for card32 values even though long isn't always 32-bit.

Sergey, can you commit this?
Comment 2 Sergey V. Udaltsov 2007-01-04 20:03:48 UTC
I am sorry - this fix does not make sense to me. Moreover, it is wrong - on platforms where sizeof gulong != 4. What I am doing is setting 32-bit (!) property on a window. May be, it is a bug in xlib (XChangeProperty function)? Since I do not have ia64, I do not know about its addressing limitations.
Comment 3 Ray Strode [halfline] 2007-01-05 03:24:52 UTC
Hi Sergey,

XChangeProperty has really counter-intuitive semantics in this regard (for historical reasons?).  The behavior is documented, though.

The man pages says,

"If the specified format is 32, the property data must be a long array"

I'm fairly confident that the fix is correct, even though the old code _seems_ like it would be more correct.
Comment 4 Sergey V. Udaltsov 2007-01-05 08:54:28 UTC
Well, the thing is that I do not like the code (and fixes) which I do not understand. So please could you explain why does this fix work?
Comment 5 Ray Strode [halfline] 2007-01-05 09:40:16 UTC
The fix works because XChangeProperty is expecting you to pass it an address to a long (from the man page as mentioned in comment 3) which on some 64-bit architures needs to be 8-byte aligned.  If you pass it the address to a CARD32 then it will only be 4-byte aligned.

When XChangeProperty tries to dereference the address passed in, it's going to do it as a long which will cause an unaligned access message because the pointer passed in isn't on an 8-byte boundry.

I think it boils down to the original author of XChangeProperty assuming long is 32-bit, which is not always the case.  The upshot is that XChangeProperty has a weird, counter-intuitive interface.

Owen, can you confirm what I'm saying is correct?
Comment 6 Sergey V. Udaltsov 2007-01-05 18:39:13 UTC
If what you're saying is correct, it mean xorg should be fixed (i.e. xlibc), not libxklavier. It's their bug.
Comment 7 Owen Taylor 2007-02-23 19:18:34 UTC
Yes, using long for format=32 was a weird and incorrect decision, but it is
unfortunately simply how Xlib works at this point. Any change would be API
and ABI compatibility. It's not going to happen. You have to make your code
work with the Xlib API as it exists.
Comment 8 Behdad Esfahbod 2007-02-23 19:38:01 UTC
My guess is that when the Xlib API was being written, there was no autoconf and no C99 stdint.h.  So they limited themselves to types defined by the C standard of then, that is, char, short, int, long, with the assumptions that sizeof(char)>=1, sizeof(short)>=2, sizeof(long)>=4.  In XRender, it's also assumed that sizeof(int)>=4.

The CARD8, CARD16, CARD32 stuff are mostly relevant in the X protocol, not public libraries.
Comment 9 Sergey V. Udaltsov 2007-02-23 21:56:17 UTC
Ok. This solution is questionable, but since it xlib suxx at that point, I'll do it.
Comment 10 Sergey V. Udaltsov 2007-02-23 22:00:15 UTC
Committed. Thanks lads for the discussion and the explanation.