authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-11-19 15:29:21+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-11-20 10:42:21+00:00
logbc524a2b1a6e5cd13c0093bed240b06d23e1a882
tree546f7bb2a13bfe917eae49876dbdeeedb17540f9
parent0f06b5b58387eacb53448835cbcbca10cca1559e
signaturelock-open Commit is signed but in an unrecognized format.

std.Build: fix crashes running fuzz tests


2 files changed, 16 insertions(+), 2 deletions(-)

lib/std/Build/Step/Compile.zig+5
......@@ -1932,6 +1932,11 @@ pub fn rebuildInFuzzMode(c: *Compile, gpa: Allocator, progress_node: std.Progres
19321932 c.step.result_error_bundle.deinit(gpa);
19331933 c.step.result_error_bundle = std.zig.ErrorBundle.empty;
19341934
1935 if (c.step.result_failed_command) |cmd| {
1936 gpa.free(cmd);
1937 c.step.result_failed_command = null;
1938 }
1939
19351940 const zig_args = try getZigArgs(c, true);
19361941 const maybe_output_bin_path = try c.step.evalZigProcess(zig_args, progress_node, false, null, gpa);
19371942 return maybe_output_bin_path.?;
lib/std/Build/Step/Run.zig+11-2
......@@ -1140,6 +1140,12 @@ pub fn rerunInFuzzMode(
11401140 .output_file, .output_directory => unreachable,
11411141 }
11421142 }
1143
1144 if (run.step.result_failed_command) |cmd| {
1145 fuzz.gpa.free(cmd);
1146 run.step.result_failed_command = null;
1147 }
1148
11431149 const has_side_effects = false;
11441150 const rand_int = std.crypto.random.int(u64);
11451151 const tmp_dir_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
......@@ -1150,7 +1156,7 @@ pub fn rerunInFuzzMode(
11501156 .web_server = null, // only needed for time reports
11511157 .ttyconf = fuzz.ttyconf,
11521158 .unit_test_timeout_ns = null, // don't time out fuzz tests for now
1153 .gpa = undefined, // not used by `runCommand`
1159 .gpa = fuzz.gpa,
11541160 }, .{
11551161 .unit_test_index = unit_test_index,
11561162 .fuzz = fuzz,
......@@ -1870,7 +1876,10 @@ fn pollZigTest(
18701876 // test. For instance, if the test runner leaves this much time between us requesting a test to
18711877 // start and it acknowledging the test starting, we terminate the child and raise an error. This
18721878 // *should* never happen, but could in theory be caused by some very unlucky IB in a test.
1873 const response_timeout_ns = @max(options.unit_test_timeout_ns orelse 0, 60 * std.time.ns_per_s);
1879 const response_timeout_ns: ?u64 = ns: {
1880 if (fuzz_context != null) break :ns null; // don't timeout fuzz tests
1881 break :ns @max(options.unit_test_timeout_ns orelse 0, 60 * std.time.ns_per_s);
1882 };
18741883
18751884 const stdout = poller.reader(.stdout);
18761885 const stderr = poller.reader(.stderr);