From 0ccfae746915545baf42e5fe33787dfdaf961c17 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Mon, 27 Oct 2025 23:15:41 +0000 Subject: [PATCH] Fix Windows build by skipping unserializable trace fields On Windows, std.json.stringify was failing when encountering pointers to opaque or function types in trace data. This commit adds compile-time checks to skip fields that can't be serialized: - Skip pointers to opaque types (*anyopaque) - Skip pointers to function types (*fn) - Skip function types directly The tracing system now safely handles all field types across platforms while still capturing all the useful data (paths, sizes, error codes, etc). All 19 trace tests pass, and cross-platform builds succeed (49/49 steps). --- src/output.zig | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/output.zig b/src/output.zig index 3d7c2f365b..20b4d57c80 100644 --- a/src/output.zig +++ b/src/output.zig @@ -1382,14 +1382,36 @@ fn Tracer(comptime ns: []const u8) type { var first = true; inline for (args_info.@"struct".fields) |field| { if (comptime !std.mem.eql(u8, field.name, "call")) { - if (!first) { - w.writeAll(",") catch return; + const field_value = @field(args, field.name); + const FieldType = @TypeOf(field_value); + const field_info = @typeInfo(FieldType); + + // Skip fields that can't be serialized (function pointers, opaque pointers, etc.) + const should_skip = comptime blk: { + if (field_info == .pointer) { + // Skip if pointing to opaque or function types + const child_info = @typeInfo(field_info.pointer.child); + if (child_info == .@"opaque" or child_info == .@"fn") { + break :blk true; + } + } else if (field_info == .@"fn") { + break :blk true; + } + break :blk false; + }; + + if (!should_skip) { + if (!first) { + w.writeAll(",") catch return; + } + first = false; + w.writeAll("\"") catch return; + w.writeAll(field.name) catch return; + w.writeAll("\":") catch return; + + // Stringify the field value - should be safe now + std.json.stringify(field_value, .{}, w) catch return; } - first = false; - w.writeAll("\"") catch return; - w.writeAll(field.name) catch return; - w.writeAll("\":") catch return; - std.json.stringify(@field(args, field.name), .{}, w) catch return; } } }