Skip Menu |

This queue is for tickets about the Digest-MD5 CPAN distribution.

Report information
The Basics
Id: 35823
Status: resolved
Priority: 0/
Queue: Digest-MD5

People
Owner: Nobody in particular
Requestors: ntyni [...] iki.fi
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.36
Fixed in: (no value)



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);
No idea.
From: Marc Pignat <marc [...] pignat.org>
Hi all! This bug has been solved in Debian, for more details you can see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=289884. In brief, the md5sum is wrong because of wrong alignment in memory access. The MD5.xs file is ok (it manages unaligned access), but the Configure scripts fails to detect the problem. Here is the patch (tested against perl 5.10) we used, to prevent gcc optimizing away unaligned access: diff --git a/Configure b/Configure index 01fa3c0..19327b7 100755 --- a/Configure +++ b/Configure @@ -18549,8 +18549,8 @@ $signal_t bletch(int s) { exit(4); } #endif int main() { #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321 - U8 buf[8]; - U32 *up; + volatile U8 buf[8]; + volatile U32 *up; int i; if (sizeof(U32) != 4) { -- 1.7.1 I will try this patch on 5.12.1. Best regards Marc
Applied as <http://github.com/gisle/digest- md5/commit/b1c5700d90fd500179d103b8139153306d2be2de> to Digest-MD5 itself and passed on to p5p: <http://thread.gmane.org/gmane.comp.lang.perl.perl5.porters/83389>.