authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-25 17:16:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-25 17:16:41-07:00
log52a13f6a7fb0933c065348128ee3e9aecd64255b
tree84fc0d2b964b93364421a973fd1cf7946ae8363b
parent2da8ec9865b6b086341b0f01334f27a488bc220a

web ui: fix not sending initial context sometimes

This would cause the web ui to crash in js or wasm.

1 files changed, 8 insertions(+), 2 deletions(-)

lib/std/Build/Fuzz.zig+8-2
...@@ -257,7 +257,12 @@ pub fn serveSourcesTar(fuzz: *Fuzz, req: *std.http.Server.Request) !void {...@@ -257,7 +257,12 @@ pub fn serveSourcesTar(fuzz: *Fuzz, req: *std.http.Server.Request) !void {
257pub const Previous = struct {257pub const Previous = struct {
258 unique_runs: usize,258 unique_runs: usize,
259 entry_points: usize,259 entry_points: usize,
260 pub const init: Previous = .{ .unique_runs = 0, .entry_points = 0 };260 sent_source_index: bool,
261 pub const init: Previous = .{
262 .unique_runs = 0,
263 .entry_points = 0,
264 .sent_source_index = false,
265 };
261};266};
262pub fn sendUpdate(267pub fn sendUpdate(
263 fuzz: *Fuzz,268 fuzz: *Fuzz,
...@@ -280,7 +285,8 @@ pub fn sendUpdate(...@@ -280,7 +285,8 @@ pub fn sendUpdate(
280 const n_runs = @atomicLoad(usize, &cov_header.n_runs, .monotonic);285 const n_runs = @atomicLoad(usize, &cov_header.n_runs, .monotonic);
281 const unique_runs = @atomicLoad(usize, &cov_header.unique_runs, .monotonic);286 const unique_runs = @atomicLoad(usize, &cov_header.unique_runs, .monotonic);
282 {287 {
283 if (unique_runs != 0 and prev.unique_runs == 0) {288 if (!prev.sent_source_index) {
289 prev.sent_source_index = true;
284 // We need to send initial context.290 // We need to send initial context.
285 const header: abi.SourceIndexHeader = .{291 const header: abi.SourceIndexHeader = .{
286 .directories_len = @intCast(coverage_map.coverage.directories.entries.len),292 .directories_len = @intCast(coverage_map.coverage.directories.entries.len),