On Wed, Apr 28, 2004 at 01:04:26PM +0200, Klewinghaus, Peter wrote:
> The cause of the unaligned access messages is a cast in myldr/sha.c, sub
> sha_transform, line 97.
>
> For tracing the error, we compiled PAR with additional cc option -g and
> ran dbx on static, pc=0x1201c785c:
>
> /usr/local/PAR-0.80/myldr> dbx static
> (dbx) 0x1201c785c / i
> [sha_transform:97, 0x1201c785c] ldq t6, 0(t7)
>
> This points us now to subroutine sha_transform, line 97. This subroutine
> can be found in myldr/sha1.c.
>
> ...
> 87 static void sha_transform(SHA_INFO *sha_info)
> 88 {
> 89 int i;
> 90 U8 *dp;
> 91 ULONG T, A, B, C, D, E, W[80], *WP;
> 92
> 93 dp = sha_info->data;
> 94
> 95 /* assert(sizeof(ULONG) == 4); */
> 96 for (i = 0; i < 16; ++i) {
> ==> 97 T = *((ULONG *) dp);
> 98 dp += 4;
> 99 W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
> 100 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
> 101 }
> 102
> ...
>
> Installing the current Digest::SHA1 version 2.10 from CPAN does not show
> this behavior, so it seems to be fixed there as it is not being compiled
> with the cc option -assume noaligned_objects option on Tru64 as well.
That's evil, non-portable code. It should be doing all those reads from
an unsigned char pointer.
(Unless it can ascertain that unaligned long reads work)
Nicholas Clark