JayDDee / cpuminer-opt

Optimized multi algo CPU miner
Other
774 stars 543 forks source link

3.9.5: Skein2 fails #194

Closed UselessGuru closed 5 years ago

UselessGuru commented 5 years ago
cpuminer-Avx2.exe -a skein2 -o stratum+tcp://skein2.eu.mine.zpool.ca:5233 -u **************************** -p Blackbox,c=BTC -b 4005

         **********  cpuminer-opt 3.9.5  ***********
     A CPU miner with multi algo support and optimized for CPUs
     with AES_NI and AVX2 and SHA extensions.
     BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT

CPU: Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz.
SW built on Jun 26 2019 with GCC 7.3.0.
CPU features: SSE2 AES SSE4.2 AVX AVX2.
SW features: SSE2 AES SSE4.2 AVX AVX2.
Algo features: AVX2.
Start mining with AVX2.

[2019-07-02 13:17:33] Starting Stratum on stratum+tcp://skein2.eu.mine.zpool.ca:5233
[2019-07-02 13:17:33] 6 miner threads started, using 'skein2' algorithm.
[2019-07-02 13:17:34] Stratum difficulty set to 1
[2019-07-02 13:17:34] skein2 block 1001894, network diff 2915.470

Miner just closes.

JayDDee commented 5 years ago

I just tested and it works for me. Can you give more details? Did you try a different exe, different algo, previous version? A silent exit is unusual, the miner usually displays an error message before exitting or the system displays displays a message if the miner crashes. You could also add -D to get debug output.

UselessGuru commented 5 years ago

Thanks for your quick reply.

previous version?

3.9.3.1 works fine:

cpuminer-Avx2.exe -a skein2 -o stratum+tcp://skein2.eu.mine.zpool.ca:5233 -u ****************************  -p Blackbox,c=BTC -b 4005 -D

         **********  cpuminer-opt 3.9.3.1  ***********
     A CPU miner with multi algo support and optimized for CPUs
     with AES_NI and AVX2 and SHA extensions.
     BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT

CPU: Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz.
SW built on Jun 13 2019 with GCC 7.3.0.
CPU features: SSE2 AES SSE4.2 AVX AVX2.
SW features: SSE2 AES SSE4.2 AVX AVX2.
Algo features: AVX2.
Start mining with AVX2.

[2019-07-02 15:27:00] Starting Stratum on stratum+tcp://skein2.eu.mine.zpool.ca:5233
[2019-07-02 15:27:00] 6 miner threads started, using 'skein2' algorithm.
[2019-07-02 15:27:00] Binding thread 0 to cpu 0.
[2019-07-02 15:27:00] Binding thread 1 to cpu 1.
[2019-07-02 15:27:00] Binding thread 2 to cpu 2.
[2019-07-02 15:27:00] Binding thread 3 to cpu 3.
[2019-07-02 15:27:00] Binding thread 4 to cpu 4.
[2019-07-02 15:27:00] Binding thread 5 to cpu 5.
[2019-07-02 15:27:01] Stratum session id: 523a682d724b0a7c113d5bba0ab6d14d
[2019-07-02 15:27:01] Stratum difficulty set to 1
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=00000000 ntime=5d1b5b95
[2019-07-02 15:27:01] skein2 block 1001968, network diff 2884.602
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=01000000 ntime=5d1b5b95
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=02000000 ntime=5d1b5b95
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=03000000 ntime=5d1b5b95
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=04000000 ntime=5d1b5b95
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=05000000 ntime=5d1b5b95
[2019-07-02 15:27:01] DEBUG: job_id='f64c' extranonce2=06000000 ntime=5d1b5b95
[2019-07-02 15:27:02] CPU #2: 524.29 kH, 2240.58 kH/s
[2019-07-02 15:27:02] CPU #5: 524.29 kH, 2259.86 kH/s
[2019-07-02 15:27:02] CPU #1: 524.29 kH, 2212.20 kH/s
[2019-07-02 15:27:02] CPU #4: 524.29 kH, 2193.69 kH/s
[2019-07-02 15:27:02] CPU #0: 524.29 kH, 1820.77 kH/s
[2019-07-02 15:27:02] CPU #3: 524.29 kH, 1820.63 kH/s
[2019-07-02 15:27:04] CTRL_C_EVENT received, exiting

You could also add -D

There is not much useful debug information:

cpuminer-Avx2.exe -a skein2 -o stratum+tcp://skein2.eu.mine.zpool.ca:5233 -u **************************** -p Blackbox,c=BTC -b 4005 -D

         **********  cpuminer-opt 3.9.5  ***********
     A CPU miner with multi algo support and optimized for CPUs
     with AES_NI and AVX2 and SHA extensions.
     BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT

CPU: Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz.
SW built on Jun 26 2019 with GCC 7.3.0.
CPU features: SSE2 AES SSE4.2 AVX AVX2.
SW features: SSE2 AES SSE4.2 AVX AVX2.
Algo features: AVX2.
Start mining with AVX2.

[2019-07-02 15:23:14] Starting Stratum on stratum+tcp://skein2.eu.mine.zpool.ca:5233
[2019-07-02 15:23:14] 6 miner threads started, using 'skein2' algorithm.
[2019-07-02 15:23:14] Binding thread 2 to cpu 2.
[2019-07-02 15:23:14] Binding thread 0 to cpu 0.
[2019-07-02 15:23:14] Binding thread 1 to cpu 1.
[2019-07-02 15:23:14] Binding thread 3 to cpu 3.
[2019-07-02 15:23:14] Binding thread 4 to cpu 4.
[2019-07-02 15:23:14] Binding thread 5 to cpu 5.
[2019-07-02 15:23:14] Stratum session id: 1688d65b40c53ba1056f6ea16e63a08f
[2019-07-02 15:23:14] Stratum difficulty set to 1
[2019-07-02 15:23:14] DEBUG: job_id='f647' extranonce2=00000000 ntime=5d1b5ac3
[2019-07-02 15:23:14] skein2 block 1001965, network diff 2884.602
[2019-07-02 15:23:15] DEBUG: job_id='f647' extranonce2=01000000 ntime=5d1b5ac3
[2019-07-02 15:23:15] DEBUG: job_id='f647' extranonce2=02000000 ntime=5d1b5ac3
[2019-07-02 15:23:15]

different algo

Other algos are OK (I have not tested them all)

Did you try a different exe

other variants, e.g. cpuminer-Avx.exe just die the same.

JayDDee commented 5 years ago

OK, maybe it's a Windows only problem. That usually means data misalignment. I think I know what the problem is but I'll need to test on Windows and check other algos.

The debug data is still valuable because it helps localize the crash based on the last message displayed and the first expected message not displayed because of the crash. Increasing verbosity (I should have also asked for --hash-meter) narrows the range. It's especially important when a program exits silently with no error message or any other clue.

Thanks for your good reporting.

UselessGuru commented 5 years ago

I should have also asked for --hash-meter

Not much more here :-(

cpuminer-Avx2.exe -a skein2 -o stratum+tcp://skein2.eu.mine.zpool.ca:5233 -u **************************** -p Blackbox,c=BTC -b 4005 -D  --hash-meter

         **********  cpuminer-opt 3.9.5  ***********
     A CPU miner with multi algo support and optimized for CPUs
     with AES_NI and AVX2 and SHA extensions.
     BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT

CPU: Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz.
SW built on Jun 26 2019 with GCC 7.3.0.
CPU features: SSE2 AES SSE4.2 AVX AVX2.
SW features: SSE2 AES SSE4.2 AVX AVX2.
Algo features: AVX2.
Start mining with AVX2.

[2019-07-02 16:47:42] 6 miner threads started, using 'skein2' algorithm.
[2019-07-02 16:47:42] Starting Stratum on stratum+tcp://skein2.eu.mine.zpool.ca:5233
[2019-07-02 16:47:42] Binding thread 0 to cpu 0.
[2019-07-02 16:47:42] Binding thread 4 to cpu 4.
[2019-07-02 16:47:42] Binding thread 2 to cpu 2.
[2019-07-02 16:47:42] Binding thread 3 to cpu 3.
[2019-07-02 16:47:42] Binding thread 1 to cpu 1.
[2019-07-02 16:47:42] Binding thread 5 to cpu 5.
[2019-07-02 16:47:42] Stratum session id: 7a0e114165436d7d1858a615577f699c
[2019-07-02 16:47:42] Stratum difficulty set to 1
[2019-07-02 16:47:42] DEBUG: job_id='f6b0' extranonce2=00000000 ntime=5d1b6e57
[2019-07-02 16:47:42] skein2 block 1002006, network diff 4015.826
[2019-07-02 16:47:43] DEBUG: job_id='f6b0' extranonce2=01000000 ntime=5d1b6e57
[2019-07-02 16:47:43] DEBUG: job_id='f6b0' extranonce2=02000000 ntime=5d1b6e57
[2019-07-02 16:47:43]

Thanks for your good reporting.

You're welcome. I am also willing to do some testing (if needed).

JayDDee commented 5 years ago

I've fixed it by reverting the changes from v3.9.4 but I still don't know why it crashes, and only on Windows.

I was in the process of preparing another release with another bug fix and I'll include the skein2 fix in it. But finding the root cause will take some time and will have to wait. I made the same change to many other algos and now I'm concerned they may also be broken.

I'm able to test at zpool but thanks for the offer.

Still a lot of work to do.

JayDDee commented 5 years ago

cpuminer-opt-3.9.5.1 is released, it should fix the skein crash. You can close this issue if your problem is solved.

I've opened a follow up issue to find the root cause.

https://github.com/JayDDee/cpuminer-opt/issues/195

UselessGuru commented 5 years ago

Skein2 is working in 3.9.5.1

JayDDee commented 5 years ago

Reopening to investigate further.

This appears to be a skein specific issue. The crash does not occur in the code that triggered it. The bswap-interleave optimization is common to many algos yet it seems only skein2 on Windows crashes. When the optimization is removed it doesn't crash. The crash is occurring in skein code after the bswap-interleave. Need to find exactly where.

If the problem is pointer alignment it's not the pointer I suspected (pdata) as it is confirmed correctly aligned.

JayDDee commented 5 years ago

It wasn't pointer alignment, it was a buffer overflow. The bswap-interleave optimization was only a trigger, there was nothing wrong with it.

Final hash is 32 bytes for all algos but many algos have 64 byte intermediate hash. A different recent optimization used the final hash buffer as a working buffer resulting in trying to hold 64 byte intermediate hash results in a 32 byte buffer.

The bswap-interleave optimization eliminated the need for a temporary copy of the input data which previously had provided unintended overrun space for the hash buffer. Once that overrun space was removed the underlying bug was exposed.

It's fixed in v3.9.5.4.