Alignment problem in wl_connection_demarshal()

Philip Withnall philip at
Fri Feb 1 09:51:42 PST 2013

Hi all,

Running Weston on 64-bit MIPS, I'm coming across a non-aligned access in
wl_connection_demarshal() which causes a processor trap.

Around line 740 of connection.c, demarshalling an object:

        id = (uint32_t **) extra;
        extra += sizeof *id;
        closure->args[i] = id;
        *id = p;

On 64-bit MIPS, the assignment to *id gets turned into a
store-double-word instruction (since pointer 'p' is 64 bits wide), which
must be to a 8-byte-aligned address. It's possible for 'extra' to not be
8-byte aligned, and hence for the store to not be aligned.

In the particular case I'm hitting, 'extra' is not 8-byte-aligned
because the message size is 12, but it also looks like alignment could
be changed in other ways; e.g. during handling a 'h'-type argument near
the bottom of the function, where 'extra' is incremented by the size of
an int.

This code is pretty opaque to me, and I have no idea about the
implications of changing it (does it affect the binary protocol between
clients and server?), so I have no idea how to go about fixing it.

Any thoughts?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the wayland-devel mailing list