sha1Of() crashing and incorrect result on win64

Rainer Schuetze r.sagitario at gmx.de
Thu Mar 6 13:59:28 PST 2014



On 06.03.2014 09:15, knutaf wrote:
> Hello,
>
> Apologies if I have missed some rule or convention in posting this. I'm
> new to this site and to D as a whole. I do all of my development on
> Windows and in general try to keep my programs as 64-bit unless I have a
> reason not to.
>
> I tried the following simple program, but it seems to not only be
> producing the wrong answer but also crashing (as in, my postmortem
> debugger comes up when I run it).
>
> import std.stdio;
> import std.digest.sha;
>
> void main()
> {
>      writefln("%s", toHexString(sha1Of("abc")));
> }
>
> Produces:
> 67452301EFCDAB8998BADCFE10325476C3D2E1F0
>
> and then crashes. If I build without -m64, I get
> A9993E364706816ABA3E25717850C26C9CD0D89D, which is what I was expecting.
>
> I'm also not sure how to produce the right kind of callstack or crash
> dump. I do most of my debugging with windbg, and the stack has a lot of
> scary looking mangled names that don't seem terribly helpful.
>
> I found a recent changelist where the version(Win64) has SSE3 disabled.
> I tried to incorporate that change locally, and it seems to have stopped
> it from crashing, but it still produces the wrong result.
>
> Can anyone else reproduce this? Hopefully it is just a matter of me
> messing up something simple.
>

I can reproduce your results but the crashes don't happen all the time. 
I think it is fixed in git head (the unittest there tests the "abc" 
sequence, too). The problem is that the SSE3 optimized version does not 
use the correct calling convention for Win64, so it is disabled for now.

It is not enough to just patch the phobos sources, you'll have to 
recompile phobos to get it fixed.


More information about the Digitalmars-d mailing list