[Box Backup] Workaround for struct packing problem on ARM processors (was: Another wish for 2011)
ell2 at live.se
Sat Feb 26 10:53:17 GMT 2011
I am using GCC version 4.1.3 and the bug refers to 4.1.1, but as it was only
the Debian version of GCC that was patched in that case, my version probably
has the same fault. The patch that the Debian bug report refers to
(http://gcc.gnu.org/ml/gcc-patches/2006-10/msg01115.html) says that the
pragma directive is made to work just as the GCC-specific packing attribute.
This is a bit discouraging because one of the first things I tested was to
use that attribute instead, and then the communication failed at an even
earlier stage. (Thinking about it now it might even have been that the
forked off communication process crashed on a mis-aligned memory access, but
that is just a wild guess.)
Some time in the future I will build a later version of GCC and try with
that, but for the time being I have other things that come first in this
project of mine.
On a more philosophical level (but not entirely philosophical), that the
compiler ignores the pragma directive is not strictly a fault. The C++
standard's definition (and only mention) of a pragma is:
A preprocessing directive of the form
# pragma pp-tokensopt new-line
causes the implementation to behave in an implementation-defined manner.
Any pragma that is not recognized by the implementation is ignored.
Which means that is perfectly alright for a compiler to ignore the pack
directive without any warning. A consequence is also that any use of
#pragma that relies on a certain outcome is non-portable. And indead
every answer I have found for "Why does not #pragma pack(1) work on ARM?",
and similar questions, is not a real answer but instead says "Do not do
that, it is not portable.", like in:
That said, the fact that my version of GCC ignores the #pragma pack
directive is most likely an oversight corrected in some later version (i.e.
some version released later that 2006-10 because it seems that mainline
GCC was patched then).
> Date: Thu, 24 Feb 2011 22:29:37 +0000
> From: chris at qwirx.com
> To: boxbackup at boxbackup.org
> Subject: Re: [Box Backup] Workaround for struct packing problem on ARM processors (was: Another wish for 2011)
> Hi Leif,
> On Wed, 23 Feb 2011, Chris Wilson wrote:
> > On Sat, 12 Feb 2011, Leif Linderstam wrote:
> >> Now I have made a suggested workaround for the struct packing problem.
> >> As far as I know the problem only manifests itself in the source file
> >> BackupStoreDirectory.cpp. The packing directive is ignored by the
> >> compiler and the struct en_StreamFormat is therefore automatically
> >> padded to 36 bytes, while on other platforms its size is only 34.
> > Thank you for your diligence and patience in testing this and developing
> > a workaround.
> > I would be very interested to know why the packing directive is ignored
> > on your platform, as this may have other consequences that are not
> > currently obvious to us, and may cause other code to fail in subtle
> > ways.
> > Did you find any documentation as to why the packing directive is
> > ignored by GCC on ARM?
> Which version of GCC are you using? Could it possibly be a bug that's
> already been reported and fixed in a more recent GCC, like this one?
> Cheers, Chris.
> _____ __ _
> \ __/ / ,__(_)_ | Chris Wilson Cambs UK |
> / (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Ruby/Perl/SQL Developer |
> \__/_/_/_//_/___/ | We are GNU : free your mind & your software |
> Boxbackup mailing list
> Boxbackup at boxbackup.org
More information about the Boxbackup