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...@@ -1932,6 +1932,11 @@ pub fn rebuildInFuzzMode(c: *Compile, gpa: Allocator, progress_node: std.Progres
1932 c.step.result_error_bundle.deinit(gpa);1932 c.step.result_error_bundle.deinit(gpa);
1933 c.step.result_error_bundle = std.zig.ErrorBundle.empty;1933 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
1935 const zig_args = try getZigArgs(c, true);1940 const zig_args = try getZigArgs(c, true);
1936 const maybe_output_bin_path = try c.step.evalZigProcess(zig_args, progress_node, false, null, gpa);1941 const maybe_output_bin_path = try c.step.evalZigProcess(zig_args, progress_node, false, null, gpa);
1937 return maybe_output_bin_path.?;1942 return maybe_output_bin_path.?;
lib/std/Build/Step/Run.zig+11-2
...@@ -1140,6 +1140,12 @@ pub fn rerunInFuzzMode(...@@ -1140,6 +1140,12 @@ pub fn rerunInFuzzMode(
1140 .output_file, .output_directory => unreachable,1140 .output_file, .output_directory => unreachable,
1141 }1141 }
1142 }1142 }
1143
1144 if (run.step.result_failed_command) |cmd| {
1145 fuzz.gpa.free(cmd);
1146 run.step.result_failed_command = null;
1147 }
1148
1143 const has_side_effects = false;1149 const has_side_effects = false;
1144 const rand_int = std.crypto.random.int(u64);1150 const rand_int = std.crypto.random.int(u64);
1145 const tmp_dir_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);1151 const tmp_dir_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
...@@ -1150,7 +1156,7 @@ pub fn rerunInFuzzMode(...@@ -1150,7 +1156,7 @@ pub fn rerunInFuzzMode(
1150 .web_server = null, // only needed for time reports1156 .web_server = null, // only needed for time reports
1151 .ttyconf = fuzz.ttyconf,1157 .ttyconf = fuzz.ttyconf,
1152 .unit_test_timeout_ns = null, // don't time out fuzz tests for now1158 .unit_test_timeout_ns = null, // don't time out fuzz tests for now
1153 .gpa = undefined, // not used by `runCommand`1159 .gpa = fuzz.gpa,
1154 }, .{1160 }, .{
1155 .unit_test_index = unit_test_index,1161 .unit_test_index = unit_test_index,
1156 .fuzz = fuzz,1162 .fuzz = fuzz,
...@@ -1870,7 +1876,10 @@ fn pollZigTest(...@@ -1870,7 +1876,10 @@ fn pollZigTest(
1870 // test. For instance, if the test runner leaves this much time between us requesting a test to1876 // test. For instance, if the test runner leaves this much time between us requesting a test to
1871 // start and it acknowledging the test starting, we terminate the child and raise an error. This1877 // start and it acknowledging the test starting, we terminate the child and raise an error. This
1872 // *should* never happen, but could in theory be caused by some very unlucky IB in a test.1878 // *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
1875 const stdout = poller.reader(.stdout);1884 const stdout = poller.reader(.stdout);
1876 const stderr = poller.reader(.stderr);1885 const stderr = poller.reader(.stderr);