Subject: | creates wrong digests on the arm architecture |
Hi,
there seems to be a weird bug in Digest::MD5 on the arm architecture,
reported as <http://bugs.debian.org/289884>. Although the report is old,
I have been able to reproduce this on both Perl 5.8.8 and 5.10.0, with
Digest::MD5 2.36.
Quoting the submitter:
=============
The attached file runs correctly on x86, but fails on test 10 and 11
on arm. It is based on the test case from the libmd5-perl package, but
since it was failing those two tests when running on arm, I replaced the
code with Digest::MD5 directly and it still fails. Strangely enough,
if you add the line '#' or something similar to the file at the start,
the tests pass, so there is something suttle going wrong when dealing
with file handles it would seem where some files work and some don't.
I hope this is only a problem in the MD5 code and not something more
serious in perl about handling files on arm in general. The main
difference I know of between arm and x86, is that 'char' is signed on
x86 by default and unsiged on arm by default. I have seen code break
where someone assumed char meant signed.
==============
The test is indeed very fragile wrt. line additions and removals. The
char signedness is probably the most significant difference between arm
and most other architectures. FWIW, I tried compiling Digest-MD5 with
OPTIMIZE="-fsigned-char", but that made no difference.
Although I can't (easily) get you access to an arm box if you don't have
one, I'd be happy to help in any way in debugging this.
Many thanks for Digest-MD5,
--
Niko Tyni
ntyni@debian.org
Subject: | md5.pl |
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN {print "1..14\n";}
END {print "not ok 1\n" unless $loaded;}
use Digest::MD5;
$loaded = 1;
print "ok 1\n";
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
package MD5Test;
# 2: Constructor
print (($md5 = Digest::MD5->new) ? "ok 2\n" : "not ok 2\n");
# 4: Various flavours of file-handle to addfile
open(F, "<$0");
$md5->reset;
$md5->addfile(F);
$hex = $md5->hexdigest;
print ($hex ne '' ? "ok 4\n" : "not ok 4\n");
$orig = $hex;
# 10: Other ways of reading the data -- line at a time
seek(F, 0, 0);
$md5->reset;
while (<F>)
{
$md5->add($_);
}
$hex = $md5->hexdigest;
print ($hex eq $orig ? "ok 10\n" : "not ok 10\n");
# 11: Input lines as a list to add()
seek(F, 0, 0);
$md5->reset;
$md5->add(<F>);
$hex = $md5->hexdigest;
print ($hex eq $orig ? "ok 11\n" : "not ok 11\n");
close(F);