From 122e0c26f23e765d91f0ff15533aeac2f4bc8f65 Mon Sep 17 00:00:00 2001 From: Kendall Condon Date: Wed, 22 Apr 2026 20:49:38 -0400 Subject: [PATCH 1/2] properly scan through inputs when saving fuzzing crash --- lib/std/Build/Step/Run.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 91e6a44a6915d535f8e556d3ee7898222b274a9f..83ef415756a99b8c5492141c866589f6a4d3d576 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -2360,7 +2360,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 +2397,6 @@ const FuzzTestRunner = struct { } in_f.close(io); - if (i == std.math.maxInt(u32)) return; - i += 1; }; defer in_f.close(io); -- 2.54.0 From 332d632ccceb65d2b28cceee740d794d6d7c4c2a Mon Sep 17 00:00:00 2001 From: Kendall Condon Date: Wed, 22 Apr 2026 20:53:33 -0400 Subject: [PATCH 2/2] collect all stderr on fuzzing crash --- lib/std/Build/Step/Run.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 83ef415756a99b8c5492141c866589f6a4d3d576..221a8b686027300fb0b6f645ca033787f479aa03 100644 --- 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) { @@ -2480,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; -- 2.54.0