[avahi] arm memory alignment problems

Lennart Poettering lennart at poettering.de
Thu Sep 22 09:32:01 PDT 2005


On Thu, 22.09.05 17:15, pHilipp Zabel (philipp.zabel at gmail.com) wrote:

> Hi!
> 
> I have a problem getting avahi-daemon to run on an ARM machine:

> (gdb) bt
> #0  0x40048670 in avahi_dns_packet_append_uint16 (p=0x29005, v=255)
>     at dns.c:226
> #1  0x40049640 in avahi_dns_packet_append_key (p=0x28fb0, k=0x282d8,
>     unicast_response=0) at dns.c:633
> #2  0x400422f8 in packet_add_probe_query (s=0x26ff0, p=0x28fb0, pj=0x28d40)
>     at probe-sched.c:188
> #3  0x4004244c in elapse_callback (e=0x29005, data=0x2) at probe-sched.c:236
> #4  0x40031b60 in expiration_event (timeout=0x29005, userdata=0x2)
>     at timeeventq.c:90
> #5  0x40027d3c in start_timeout_callback (t=0x28ff5) at simple-watch.c:428
> #6  0x40027e74 in avahi_simple_poll_iterate (s=0x24418, timeout=-1)
>     at simple-watch.c:481
> #7  0x0000cfd0 in run_server (c=0x22844) at main.c:628
> #8  0x0000d844 in main (argc=1, argv=0x22844) at main.c:973
> 
> ARM only supports 32 bit aligned memory accesses, afaik.
> eDoes anybody have an idea how to fix this?

The corresponding code looks like this:

<snip>
uint8_t *avahi_dns_packet_append_uint32(AvahiDnsPacket *p, uint32_t v)
{
    uint8_t *d;
    assert(p);

    if (!(d = avahi_dns_packet_extend(p, sizeof(uint32_t))))
        return NULL;

    *((uint32_t*) d) = htonl(v);  /** SIGBUS HERE **/

    return d;
}
</snip>

The pointer d is not necessarily aligned to 32bit multiples. The fix
is easy: just write all four bytes of the uint32_t value seperately
and manually to the memory d points to.

lathiat showed some interest in fixing this?

Lennart

-- 
Lennart Poettering; lennart [at] poettering [dot] de
ICQ# 11060553; GPG 0x1A015CC4; http://0pointer.de/lennart/


More information about the avahi mailing list