commit f6258b562d27aab7cfd57984e6ab51660158fc8d (tree)
parent 084eab03d75187df41fbda5e4bd78e89d96297ff
Author: Andrew Kelley <andrew@ziglang.org>
Date: Fri, 24 Apr 2026 02:31:12 +0200
Merge pull request 'fix bugs with handling fuzzing crashes' (#32033) from gooncreeper/zig:fuzz-crash-report-bugs into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/32033
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Diffstat:
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig
@@ -2166,11 +2166,15 @@ const FuzzTestRunner = struct {
const result = completion.result;
switch (completion.index % 3) {
0 => try f.completeStdinWrite(id, result.file_write_streaming catch |e| switch (e) {
- error.BrokenPipe => return f.instanceEos(id),
+ // Avoid calling `instanceEos` until EndOfStream is seen with stderr so
+ // that all stderr is collected.
+ error.BrokenPipe => continue,
else => |write_e| return write_e,
}),
1 => try f.completeStdoutRead(id, result.file_read_streaming catch |e| switch (e) {
- error.EndOfStream => return f.instanceEos(id),
+ // Avoid calling `instanceEos` until EndOfStream is seen with stderr so
+ // that all stderr is collected.
+ error.EndOfStream => continue,
else => |read_e| return read_e,
}),
2 => try f.completeStderrRead(id, result.file_read_streaming catch |e| switch (e) {
@@ -2360,7 +2364,10 @@ const FuzzTestRunner = struct {
var in_name_buf: [12]u8 = undefined;
var in_name: []const u8 = undefined;
var i: u32 = 0;
- const header: InputHeader = while (true) {
+ const header: InputHeader = while (true) : ({
+ if (i == std.math.maxInt(u32)) return;
+ i += 1;
+ }) {
const name_prefix = "f" ++ Io.Dir.path.sep_str ++ "in";
in_name = std.fmt.bufPrint(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable;
in_f = b.cache_root.handle.openFile(io, in_name, .{
@@ -2394,8 +2401,6 @@ const FuzzTestRunner = struct {
}
in_f.close(io);
- if (i == std.math.maxInt(u32)) return;
- i += 1;
};
defer in_f.close(io);
@@ -2479,7 +2484,7 @@ const FuzzTestRunner = struct {
const step_owner = f.run.step.owner;
const arena = step_owner.allocator;
- // Collect any remaining stderr
+ // Collect any available stderr
while (f.batch.next()) |completion| {
if (completion.index % 3 != 2) continue;
const len = completion.result.file_read_streaming catch continue;