Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jan 2009 13:58:06 -0200
From:      "Fernan Aguero" <fernan.aguero@gmail.com>
To:        freebsd-perl@freebsd.org
Subject:   Storable byteorder incompatibilities in different FreeBSD installations
Message-ID:  <520894aa0901020758o79bb1233teee539f6d599d10a@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
------=_Part_85910_20528024.1230911886862
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

I've been bitten by binary incompatibilitiess (bytorder, and/or byte
sizes of ints, longs, and whatnot) between two perl installations
(both on FreeBSD, using latest perl5.8 from ports).

Upon investigation, it does not seem clear to me why the two
installations should be different. And it prompted me to ask a few
questions :)

The context:
I have a perl web application running under mod_perl in FreeBSD that
dumps Perl data structures using Storable (binary format) and stores
them, after encoding them with Base64, into a MySQL database. This
application is under production and we have just deployed a test
server for development in another FreeBSD box.

Binary incompatibilities when reading the Storable binary data have
been observed in the past when running the web application from Linux
boxes (Ubuntu, i386 or amd64).

Now, they have been also observed under FreeBSD in the new test
server. This prompted us to do an investigation of the issue, because
up to now we were assuming we would have no problems if we kept our
production servers running FreeBSD.

Below is the description of each box and the output of:
perl -MConfig -le "print @Config{byteorder}"
perl -MConfig -le "print @Config{shortsize}"
perl -MConfig -le "print @Config{intsize}"
perl -MConfig -le "print @Config{longsize}"
perl -MConfig -le "print @Config{longlongsize}"
perl -V (I'm not including the full output, due to its size, only
diffs between selected cases)

1. Production server: FreeBSD-6.3, i386, perl5.8 from ports
byteorder: 12345678
shortsize: 2
intsize: 4
longsize: 4
lonlongsize: 8

2. Development/test server: FreeBSD-7.1-RC1, amd64, perl5.8 from ports
byteorder: 12345678
shortsize: 2
intsize: 4
longsize:8
lonlongsize: 8

3. Yet another server where we did some tests: FreeBSD-6.3, i386,
perl5.8 from ports, perl5.8 standalone build

perl5.8 from ports
byteorder: 12345678
shortsize: 2
intsize: 4
longsize: 4
lonlongsize: 8

perl5.8, standalone build
cd /usr/ports/lang/perl5.8 && make extract
cd work/perl-5.8.8 && ./Configure (answering all questions with the
default values except for the prefix installation)
make && make test && make install (PREFIX is /home/fernan/perl)
byteorder: 1234
shortsize: 2
intsize: 4
longsize: 4
lonlongsize: 8

As you can see, a Perl built outside of the ports system, has a
different binary configuration (and should produce incompatible
Storable images) as the Perl built from ports. As a sidenote, the
binary configuration is similar to the one found in ubuntu
pre-compiled binary perl packages (Linux, see below).

Attached to this message is a diff of the output produced by 'perl -V'
both for the perl built from the lang/perl5.8 port, and from the perl
built from sources, as explained above.

4. Other test boxes: Ubuntu-8.10, i386, perl5.8 and perl5.10
byteorder: 1234
shortsize: 2
intsize: 4
longsize: 4
lonlongsize: 8

Up to now the questions that come to mind are:

i) why is it that the perl built from ports produces binary dumps
(using Storable) with incompatible byteorder with respect to the one
built from Perl sources? (both perls were built on the same platform,
same gcc)

ii) Why does the Perl built from ports have an unusual byteorder?

iii) Why does Perl built from ports in different platforms produce
incompatible binary dumps (this time because of a difference in
longsize)? Is it because it was compiled with a different gcc (3.4.6
in FBSD-6.3 vs 4.2.1 in FBSD-7.1)? Or because it was compiled in a
different platform (amd64 vs i386)?

Reading the Configure script that comes with perl-5.8.8, and regarding
the byteorder, it says that:
"A big-endian machine like a Pyramid or a Motorola 680?0 chip will
come out to 4321. A little-endian machine like a Vax or an Intel 80?86
chip would be 1234. Other machines may have weird orders like 3412.  A
Cray will report 87654321,
an Alpha will report 12345678. If the test program works the default is
probably right. I'm now running the test program..."

So why is it that building Perl outside of the ports system makes the
test program report '1234' which is what I would expect from an i386
box, while it gives '12345678' when running from within the ports
system? Why this unusual byteorder?


And now for a pragmatic and urgent question:
iv) how can I use the ports system to build a Perl in different FBSD
boxes that would result in the same binary configuration (byteorder,
shortsize, intsize, etc.) to guarantee it would produce compatible
(i.e. readable from other FBSD boxes) dumps of Perl data structures?


Sorry for the long post, and have yourselves a happy and peaceful 2009!

-- 
fernan

------=_Part_85910_20528024.1230911886862
Content-Type: text/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NQUxMT0NfV1JBUCBVU0VfNjRfQklUX0lOVAorICAgICAgICAg
ICAgICAgICAgICAgICAgVVNFX0xBUkdFX0ZJTEVTIFVTRV9QRVJMSU8KKyAgTG9jYWxseSBhcHBs
aWVkIHBhdGNoZXM6CisJZGVmaW5lZC1vcgogICBCdWlsdCB1bmRlciBmcmVlYnNkCi0gIENvbXBp
bGVkIGF0IERlYyAyMyAyMDA4IDIwOjI2OjQzCisgIENvbXBpbGVkIGF0IE1heSAyMCAyMDA4IDEw
OjMzOjA1CiAgIEBJTkM6Ci0gICAgL2hvbWUvZmVybmFuL3BlcmwvbGliLzUuOC44L2kzODYtZnJl
ZWJzZAotICAgIC9ob21lL2Zlcm5hbi9wZXJsL2xpYi81LjguOAotICAgIC9ob21lL2Zlcm5hbi9w
ZXJsL2xpYi9zaXRlX3BlcmwvNS44LjgvaTM4Ni1mcmVlYnNkCi0gICAgL2hvbWUvZmVybmFuL3Bl
cmwvbGliL3NpdGVfcGVybC81LjguOAotICAgIC9ob21lL2Zlcm5hbi9wZXJsL2xpYi9zaXRlX3Bl
cmwKKyAgICAvdXNyL2xvY2FsL2xpYi9wZXJsNS81LjguOC9CU0RQQU4KKyAgICAvdXNyL2xvY2Fs
L2xpYi9wZXJsNS9zaXRlX3BlcmwvNS44LjgvbWFjaAorICAgIC91c3IvbG9jYWwvbGliL3Blcmw1
L3NpdGVfcGVybC81LjguOAorICAgIC91c3IvbG9jYWwvbGliL3Blcmw1L3NpdGVfcGVybAorICAg
IC91c3IvbG9jYWwvbGliL3Blcmw1LzUuOC44L21hY2gKKyAgICAvdXNyL2xvY2FsL2xpYi9wZXJs
NS81LjguOAogICAgIC4K
------=_Part_85910_20528024.1230911886862--



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