diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index b0380444f4dc..9630868d78b5 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -872,7 +872,7 @@ pub const Mutable = struct { @memset(rma.limbs[0..req_limbs], 0); - llmulacc(.add, allocator, rma.limbs, a_limbs, b_limbs); + llmulacc(.add, allocator, rma.limbs[0..req_limbs], a_limbs, b_limbs); rma.normalize(@min(req_limbs, a.limbs.len + b.limbs.len)); rma.positive = (a.positive == b.positive); rma.truncate(rma.toConst(), signedness, bit_count); diff --git a/lib/std/os/linux/IoUring.zig b/lib/std/os/linux/IoUring.zig index 25d4d88fd02f..e67abefffda5 100644 --- a/lib/std/os/linux/IoUring.zig +++ b/lib/std/os/linux/IoUring.zig @@ -1704,7 +1704,9 @@ pub const BufferGroup = struct { pub fn get(self: *BufferGroup, cqe: linux.io_uring_cqe) ![]u8 { const buffer_id = try cqe.buffer_id(); const used_len = @as(usize, @intCast(cqe.res)); - return self.get_by_id(buffer_id)[0..used_len]; + const buf = self.get_by_id(buffer_id)[0..used_len]; + std.valgrind.memcheck.makeMemDefinedIfAddressable(buf); + return buf; } // Release buffer from CQE to the kernel. @@ -2178,7 +2180,7 @@ test "write_fixed/read_fixed" { defer file.close(); const fd = file.handle; - var raw_buffers: [2][11]u8 = undefined; + var raw_buffers: [2][11]u8 = @splat(@splat(0)); // First buffer will be written to the file. @memset(&raw_buffers[0], 'z'); raw_buffers[0][0.."foobar".len].* = "foobar".*; @@ -2704,6 +2706,8 @@ test "statx" { .BADF => return error.SkipZigTest, else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), } + // buf is initialized after a successful copy_cqe + std.valgrind.memcheck.makeMemDefinedIfAddressable(std.mem.sliceAsBytes(std.mem.asBytes(&buf))); try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0xaaaaaaaa, .res = 0, @@ -3206,6 +3210,7 @@ test "provide_buffers: read" { const buffer_len = 128; var buffers: [4][buffer_len]u8 = undefined; + std.valgrind.memcheck.makeMemDefinedIfAddressable(std.mem.sliceAsBytes(&buffers)); // Provide 4 buffers @@ -3338,6 +3343,7 @@ test "remove_buffers" { const buffer_len = 128; var buffers: [4][buffer_len]u8 = undefined; + std.valgrind.memcheck.makeMemDefinedIfAddressable(std.mem.sliceAsBytes(&buffers)); // Provide 4 buffers @@ -4052,7 +4058,7 @@ test "waitid" { posix.exit(7); } - var siginfo: posix.siginfo_t = undefined; + var siginfo = std.mem.zeroes(posix.siginfo_t); _ = try ring.waitid(0, .PID, pid, &siginfo, posix.W.EXITED, 0); try testing.expectEqual(1, try ring.submit()); @@ -4416,9 +4422,7 @@ fn expect_buf_grp_cqe( try testing.expectEqual(posix.E.SUCCESS, cqe.err()); // get buffer from pool - const buffer_id = try cqe.buffer_id(); - const len = @as(usize, @intCast(cqe.res)); - const buf = buf_grp.get_by_id(buffer_id)[0..len]; + const buf = try buf_grp.get(cqe); try testing.expectEqualSlices(u8, expected, buf); return cqe; @@ -4599,6 +4603,8 @@ fn testSendRecv(ring: *IoUring, send_fd: posix.socket_t, recv_fd: posix.socket_t try testing.expectEqual(posix.E.SUCCESS, cqe.err()); recv_len += @intCast(cqe.res); } + // if this is not the case, the check fails + std.valgrind.memcheck.makeMemDefinedIfAddressable(&buffer_recv); // inspect recv buffer try testing.expectEqualSlices(u8, buffer_send, buffer_recv[0..buffer_send.len]); diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig index e38687dbde10..375ff36fb508 100644 --- a/lib/std/os/linux/test.zig +++ b/lib/std/os/linux/test.zig @@ -120,9 +120,6 @@ test "fadvise" { var file = try tmp.dir.createFile(tmp_file_name, .{}); defer file.close(); - var buf: [2048]u8 = undefined; - try file.writeAll(&buf); - const ret = linux.fadvise(file.handle, 0, 0, linux.POSIX_FADV.SEQUENTIAL); try expectEqual(@as(usize, 0), ret); } @@ -244,7 +241,7 @@ test "futex v1" { try expectEqual(0, rc); // CMP_REQUEUE - val3 mismatch - rc = linux.futex(&lock.raw, .{ .cmd = .CMP_REQUEUE, .private = true }, 2, .{ .val2 = 0 }, null, 99); + rc = linux.futex(&lock.raw, .{ .cmd = .CMP_REQUEUE, .private = true }, 2, .{ .val2 = 0 }, &lock.raw, 99); try expectEqual(.AGAIN, linux.E.init(rc)); // CMP_REQUEUE - requeue (but no waiters, so ... not much)