Subject: Re: unaligned access: how to track ?
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Chris G. Demetriou <cgd@netbsd.org>
List: port-alpha
Date: 06/07/2000 07:49:22
Manuel Bouyer <bouyer@antioche.lip6.fr> writes:
> I get unalligned access from rpc.statd:
> pid 146 (rpc.statd): unaligned access: va=0x120119feb pc=0x1200023a4 ra=0x1200021ec op=ldq
>
> What does usually cause this ? How can I track this down ?
sysctl -w machdep.unaligned_sigbus=1
then you'll get a core.
this is ususally caused by casting inadequately-aligned pointers to
(long *) (or (int *), but that's not the case here).
this can be as simple as:
char *cp = some unaligned address;
foo = *(long *)cp
note that gcc will also emit ... interesting inline code for
e.g. memcpy, at least on some archs (of which i think one is alpha),
such that if you say:
long *lp = some unaligned address;
memcpy(foo, lp, ...)
you may get unaligned accesses because it's decided that since 'lp' is
a (long *) it's properly aligned, and open-codes the move based on
that. Whether or not this is a reasonable assumption for memcpy() et
al. is ... up for debate. (for structure copies, it's obviously
correct... but memcpy() isn't so clear. A non-inlined memcpy()
couldn't make such assumptions, and it's not clear that the inliner
should be, since memcpy()'s args are void *, which isn't guaranteed to
be aligned any particular way. 8-)
cgd
--
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.