std.Build: fix crashes running fuzz tests

This commit is contained in:
Matthew Lugg 2025-11-19 15:29:21 +00:00
parent 0f06b5b583
commit bc524a2b1a
No known key found for this signature in database
GPG Key ID: 3F5B7DCCBF4AF02E
2 changed files with 16 additions and 2 deletions

View File

@ -1932,6 +1932,11 @@ pub fn rebuildInFuzzMode(c: *Compile, gpa: Allocator, progress_node: std.Progres
c.step.result_error_bundle.deinit(gpa); c.step.result_error_bundle.deinit(gpa);
c.step.result_error_bundle = std.zig.ErrorBundle.empty; c.step.result_error_bundle = std.zig.ErrorBundle.empty;
if (c.step.result_failed_command) |cmd| {
gpa.free(cmd);
c.step.result_failed_command = null;
}
const zig_args = try getZigArgs(c, true); const zig_args = try getZigArgs(c, true);
const maybe_output_bin_path = try c.step.evalZigProcess(zig_args, progress_node, false, null, gpa); const maybe_output_bin_path = try c.step.evalZigProcess(zig_args, progress_node, false, null, gpa);
return maybe_output_bin_path.?; return maybe_output_bin_path.?;

View File

@ -1140,6 +1140,12 @@ pub fn rerunInFuzzMode(
.output_file, .output_directory => unreachable, .output_file, .output_directory => unreachable,
} }
} }
if (run.step.result_failed_command) |cmd| {
fuzz.gpa.free(cmd);
run.step.result_failed_command = null;
}
const has_side_effects = false; const has_side_effects = false;
const rand_int = std.crypto.random.int(u64); const rand_int = std.crypto.random.int(u64);
const tmp_dir_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int); const tmp_dir_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
@ -1150,7 +1156,7 @@ pub fn rerunInFuzzMode(
.web_server = null, // only needed for time reports .web_server = null, // only needed for time reports
.ttyconf = fuzz.ttyconf, .ttyconf = fuzz.ttyconf,
.unit_test_timeout_ns = null, // don't time out fuzz tests for now .unit_test_timeout_ns = null, // don't time out fuzz tests for now
.gpa = undefined, // not used by `runCommand` .gpa = fuzz.gpa,
}, .{ }, .{
.unit_test_index = unit_test_index, .unit_test_index = unit_test_index,
.fuzz = fuzz, .fuzz = fuzz,
@ -1870,7 +1876,10 @@ fn pollZigTest(
// test. For instance, if the test runner leaves this much time between us requesting a test to // test. For instance, if the test runner leaves this much time between us requesting a test to
// start and it acknowledging the test starting, we terminate the child and raise an error. This // start and it acknowledging the test starting, we terminate the child and raise an error. This
// *should* never happen, but could in theory be caused by some very unlucky IB in a test. // *should* never happen, but could in theory be caused by some very unlucky IB in a test.
const response_timeout_ns = @max(options.unit_test_timeout_ns orelse 0, 60 * std.time.ns_per_s); const response_timeout_ns: ?u64 = ns: {
if (fuzz_context != null) break :ns null; // don't timeout fuzz tests
break :ns @max(options.unit_test_timeout_ns orelse 0, 60 * std.time.ns_per_s);
};
const stdout = poller.reader(.stdout); const stdout = poller.reader(.stdout);
const stderr = poller.reader(.stderr); const stderr = poller.reader(.stderr);