On Fri, Oct 16, 2015 at 3:16 PM, Yann Ylavic <ylavic....@gmail.com> wrote:
> On Fri, Oct 16, 2015 at 3:08 PM, Rainer Jung <rainer.j...@kippdata.de> wrote:
>>
>> Wasn't the bus error occuring in
>>
>> ws->last_used = apr_time_now();
>>
>> and the address is
>>
>> (dbx) print &(ws->last_used)
>> &ws->last_used = 0xffffffff7bb00094
>>
>> not divisible by 8 although the data type (not pointer size) is 64 Bit.
>
> Yes but ws itself isn't aligned either:
>     (dbx) print ws
>     ws = 0xffffffff7bb00044
> which is IMHO the issue.
>
> Align ws and everything goes well (at least I think :p ).

Hm (again), you may be right.
On sparc32 still, the compiler would do the alignment correctly for
the allocated struct if it contained a 64 bit type (forcing an 8 bytes
alignment), but we are not using malloc() here.
Since we assign the address by ourselves but don't (can't) know
whether it contains a 64bit type, we must align on 8 bytes boundary,
otherwise things like:
    struct s {
        apr_int64_t i64;
        ...
    };
could fault when s->i64 is used.

That's probably why APR_ALIGN_DEFAULT(1) is always 8 which is the
largest integral type handle by the APR.
Thanks for the remainder!

Reply via email to