authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-24 02:31:12+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-24 02:31:12+02:00
logf6258b562d27aab7cfd57984e6ab51660158fc8d
treef08d15a4b1d9ef3c8a1b96fd721e0616f3e7a966
parent084eab03d75187df41fbda5e4bd78e89d96297ff
parent332d632ccceb65d2b28cceee740d794d6d7c4c2a

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>

1 files changed, 11 insertions(+), 6 deletions(-)

lib/std/Build/Step/Run.zig+11-6
......@@ -2166,11 +2166,15 @@ const FuzzTestRunner = struct {
21662166 const result = completion.result;
21672167 switch (completion.index % 3) {
21682168 0 => try f.completeStdinWrite(id, result.file_write_streaming catch |e| switch (e) {
2169 error.BrokenPipe => return f.instanceEos(id),
2169 // Avoid calling `instanceEos` until EndOfStream is seen with stderr so
2170 // that all stderr is collected.
2171 error.BrokenPipe => continue,
21702172 else => |write_e| return write_e,
21712173 }),
21722174 1 => try f.completeStdoutRead(id, result.file_read_streaming catch |e| switch (e) {
2173 error.EndOfStream => return f.instanceEos(id),
2175 // Avoid calling `instanceEos` until EndOfStream is seen with stderr so
2176 // that all stderr is collected.
2177 error.EndOfStream => continue,
21742178 else => |read_e| return read_e,
21752179 }),
21762180 2 => try f.completeStderrRead(id, result.file_read_streaming catch |e| switch (e) {
......@@ -2360,7 +2364,10 @@ const FuzzTestRunner = struct {
23602364 var in_name_buf: [12]u8 = undefined;
23612365 var in_name: []const u8 = undefined;
23622366 var i: u32 = 0;
2363 const header: InputHeader = while (true) {
2367 const header: InputHeader = while (true) : ({
2368 if (i == std.math.maxInt(u32)) return;
2369 i += 1;
2370 }) {
23642371 const name_prefix = "f" ++ Io.Dir.path.sep_str ++ "in";
23652372 in_name = std.fmt.bufPrint(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable;
23662373 in_f = b.cache_root.handle.openFile(io, in_name, .{
......@@ -2394,8 +2401,6 @@ const FuzzTestRunner = struct {
23942401 }
23952402
23962403 in_f.close(io);
2397 if (i == std.math.maxInt(u32)) return;
2398 i += 1;
23992404 };
24002405 defer in_f.close(io);
24012406
......@@ -2479,7 +2484,7 @@ const FuzzTestRunner = struct {
24792484 const step_owner = f.run.step.owner;
24802485 const arena = step_owner.allocator;
24812486
2482 // Collect any remaining stderr
2487 // Collect any available stderr
24832488 while (f.batch.next()) |completion| {
24842489 if (completion.index % 3 != 2) continue;
24852490 const len = completion.result.file_read_streaming catch continue;