Skip to content

std lib test suite: fix illegal behavior found by valgrind - #24833

Closed
ghost wants to merge 11 commits into
masterfrom
unknown repository
Closed

std lib test suite: fix illegal behavior found by valgrind#24833
ghost wants to merge 11 commits into
masterfrom
unknown repository

Conversation

@ghost

Copy link
Copy Markdown

this addresses some of the warnings in #24753

@jedisct1

Copy link
Copy Markdown
Contributor

That fix doesn't make sense.

Maybe move var ad = m; later, after m has been initialized instead.

Comment threadlib/std/os/linux/test.zig
Comment threadlib/std/os/linux/test.zig Outdated
@rpkak

Copy link
Copy Markdown
Contributor

I also just fixed the IOUring errors. This is my diff:

diff --git a/lib/std/os/linux/IoUring.zig b/lib/std/os/linux/IoUring.zig
index 62a87ac103..5c7e5ff1c2 100644
--- a/lib/std/os/linux/IoUring.zig+++ b/lib/std/os/linux/IoUring.zig@@ -1692,7 +1692,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.
@@ -4404,9 +4406,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;

@ghost

Copy link
Copy Markdown
Author

I also just fixed the IOUring errors. This is my diff:

I committed it, feel free to change the author

@rpkak

Copy link
Copy Markdown
Contributor

I also just fixed the IOUring errors. This is my diff:

I committed it, feel free to change the author

That's not important to me.

@rpkak

Copy link
Copy Markdown
Contributor

I think b349081 and fc1a66e can be reverted now.

@ghost

Copy link
Copy Markdown
Author

I think b349081 and fc1a66e can be reverted now.

Tested, reverting either increases the amount of valgrind errors.

@andrewrkandrewrk changed the title std lib test suite: silence valgrind warningsstd lib test suite: fix illegal behavior found by valgrindAug 13, 2025
@andrewrk

Copy link
Copy Markdown
Member

I edited the title to better reflect the task: fixing things, not suppressing warnings

Comment threadlib/std/Build.zig
.graph = graph,
.build_root = build_root,
.cache_root = cache_root,
.debug_stack_frames_count = std.Build.debug_stack_frames_count, // strange: errors out as undeclared without the prefixes

@ghostghostAug 14, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also errors out when running the std lib test suite
how do I fix this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jedisct1 any ideas on this? I could just hardcode 8, but that seems like a bug waiting to happen.

@ghost

Copy link
Copy Markdown
Author

no valgrind errors on linux, tested with .debug_stack_frames_count = 8 (don't know how to fix that)
valgrind.txt

Comment threadlib/std/math/big/int.zig
@andrewrk

Copy link
Copy Markdown
Member

I have a feeling this is never going to get merged. Please do one at a time, and no drafts

Comment threadlib/std/os/linux/IoUring.zig
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@jedisct1@rpkak@andrewrk@nektro