RustCrypto / asm-hashes

Assembly implementations of cryptographic hash functions
46 stars 26 forks source link

bench failed on Windows #37

Closed chawyehsu closed 5 months ago

chawyehsu commented 3 years ago

env: Windows 10 x86_64, Rust nightly-gnu [rustc 1.55.0-nightly (539d7bd39 2021-06-14)]

❯ cargo +nightly-gnu bench -vvv
       Fresh cc v1.0.61
       Fresh md5-asm v0.5.0 (C:\workspace\repos\github.com\RustCrypto\asm-hashes\md5)
    Finished bench [optimized] target(s) in 0.04s
     Running `C:\workspace\repos\github.com\RustCrypto\asm-hashes\target\release\deps\md5_asm-4aede987d9726e5b.exe --bench`

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running `C:\workspace\repos\github.com\RustCrypto\asm-hashes\target\release\deps\lib-dab98c6ec0ebcfb5.exe --bench`

running 1 test
error: bench failed

How can I fix this?

tarcieri commented 3 years ago

Hmm, I'm not quite sure what's happening there. While we do have CI for those environments, we don't test the benchmarks, nor do I have access to a Windows machine to confirm myself.

I've never seen "bench failed" before. Is it panicking?

Can you try going into the individual directories and running the benchmarks? It looks like md5-asm is failing there, but do the other benchmarks fail in the same way if you run them individually?

chawyehsu commented 3 years ago

@tarcieri Unfortunately, I ran them individually and all of them fail with the same error and no other output. The build is successful, but I don't know it's panicking or not since the only message I can see is the one of error: bench failed.

tarcieri commented 3 years ago

Wow, that's really confusing.

Can you try running the binary under a debugger like gdb? Something like:

$ gdb C:\workspace\repos\github.com\RustCrypto\asm-hashes\target\release\deps\lib-dab98c6ec0ebcfb5.exe
(gdb) run --bench
chawyehsu commented 3 years ago
(gdb) run --bench
Starting program: C:\workspace\repos\github.com\RustCrypto\asm-hashes\target\release\deps\lib-be2dc135b8dd9613.exe --bench
[New Thread 5852.0x4c18]
[New Thread 5852.0x8688]
[New Thread 5852.0x5fe0]

running 1 test

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff6dcb61f1d in md5_compress ()
(gdb) info registers
rax            0x1fe64             130660
rbx            0x8b741fe6a0        598948701856
rcx            0x8b741fe6a0        598948701856
rdx            0x11034064          285425764
rsi            0x7d0               2000
rdi            0x11034064          285425764
rbp            0x7d0               0x7d0
rsp            0x8b741fe2a8        0x8b741fe2a8
r8             0xff                255
r9             0x7ffee000          2147409920
r10            0x1                 1
r11            0x467e00b301        302761685761
r12            0x8b741fe3e0        598948701152
r13            0x8b741fe370        598948701040
r14            0x8b741fe3e8        598948701160
r15            0x8b741fe300        598948700928
rip            0x7ff6dcb61f1d      0x7ff6dcb61f1d <md5_compress+13>
eflags         0x10206             [ PF IF RF ]
cs             0x33                51
ss             0x2b                43
ds             0x2b                43
es             0x2b                43
fs             0x53                83
gs             0x2b                43
tarcieri commented 3 years ago

Okay, that's helpful! Can you run info registers?

chawyehsu commented 3 years ago

I edited the comment and added the info.

tarcieri commented 3 years ago

Thanks! I'll try to look into this a bit more when I have time, but it seems like the kind of problem where I might need to set up a Windows VM to debug.

Really we should probably just switch to better assembly implementations (see #5)