Alignment problem in wl_connection_demarshal()

Kristian Høgsberg hoegsberg at
Thu Feb 7 18:16:30 PST 2013

On Fri, Feb 01, 2013 at 05:51:42PM +0000, Philip Withnall wrote:
> 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?

It's an issue we've hit before.  I posted a patch in, give that a try.


More information about the wayland-devel mailing list