zig
zig copied to clipboard
Regression: std.crypto.hash.Sha1.hash() stops working on 32-bit Windows
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
test "sha1" {
var digest: [std.crypto.hash.Sha1.digest_length]u8 = undefined;
std.crypto.hash.Sha1.hash(&.{}, &digest, .{});
std.debug.print("\n{any}\n", .{digest});
}
$ zig test generate-sha1-hash.zig -target x86-windows
{ 235, thread 220, 1615218 panic: , integer overflow
183, 106, 128, 211, 89, 241, 117, 97, 33, 108, 190, 96, 143, 70, 47, 121, 187 }
error: the following test command failed with exit code 5:
Expected Behavior
Using 0.12.0:
$ zig test generate-sha1-hash.zig -target x86-windows
Test [1/1] generate-sha1-hash.test.sha1...
{ 218, 57, 163, 238, 94, 107, 75, 13, 50, 85, 191, 239, 149, 96, 24, 144, 175, 216, 7, 9 }
All 1 tests passed.
Same result using 0.13.0 on 64-bit Windows.
Might be a consequence of #20469. lib/std/crypto/sha1.zig hasn't changed in the last 9 months according to git log. This is likely related to the change to LLVM 18.
x86-windows has known miscompilations since the LLVM 18 upgrade:
#20047