Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jan 2008 13:54:39 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Willem Jan Withagen <wjw@digiware.nl>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: sshd broken on arm?
Message-ID:  <86hch25als.fsf@ds4.des.no>
In-Reply-To: <20080125113916.GP81396@plum.flirble.org> (Nicholas Clark's message of "Fri\, 25 Jan 2008 11\:39\:16 %2B0000")
References:  <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> <47991E08.6070609@digiware.nl> <20080125041540.GA30262@zibbi.meraka.csir.co.za> <4799A2B3.4060003@digiware.nl> <86prvq5eua.fsf@ds4.des.no> <20080125113916.GP81396@plum.flirble.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Nicholas Clark <nick@ccl4.org> writes:
> On Fri, Jan 25, 2008 at 12:23:09PM +0100, Dag-Erling Smrgrav wrote:
> > None of this matters.  What John pointed out means that the code is
> > wrong and the compiler is right.  The code is not allowed to assume
> > that an object is correctly aligned unless it is of a type that
> > requires the correct alignment.  The easiest way to do this is with
> > a union, e.g.
> Whilst that is correct, why is the compiler changing the alignment of the
> struct for different optimiser settings but all other flags identical?

Because *it is not a struct*.

It is an array of char, and char has no special alignment requirement.

The bug is in the code, which uses pointer aliasing in a way that is
strictly speaking legal but which places responsibility for alignment
issues squarely in the code and not the compiler.

IIRC, this is precisely the same issue that we had in libalias when the
checksum recalculation broke because it was doing unaligned 16-bit
accesses (many years ago now, see twowords() in alias.c)

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86hch25als.fsf>