Skip to content

Commit 3ee7cae

Browse files
committed
fuzzer fixes
1 parent 376839f commit 3ee7cae

31 files changed

+426
-525
lines changed

build.zig

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn build(b: *std.Build) !void {
2222
const superhtml = b.addModule("superhtml", .{
2323
.root_source_file = b.path("src/root.zig"),
2424
.target = target,
25+
.optimize = optimize,
2526
});
2627
superhtml.addImport("scripty", scripty.module("scripty"));
2728
superhtml.addImport("tracy", tracy.module("tracy"));
@@ -64,6 +65,22 @@ pub fn build(b: *std.Build) !void {
6465
if (version == .tag) {
6566
setupReleaseStep(b, options, superhtml, folders, lsp);
6667
}
68+
69+
setupGeneratorStep(b, target);
70+
}
71+
72+
fn setupGeneratorStep(b: *std.Build, target: std.Build.ResolvedTarget) void {
73+
const gen = b.step("generator", "Build generator executable for reproing fuzz cases");
74+
const supergen = b.addExecutable(.{
75+
.name = "generator",
76+
.root_module = b.createModule(.{
77+
.root_source_file = b.path("src/generator.zig"),
78+
.target = target,
79+
.optimize = .ReleaseSafe,
80+
}),
81+
});
82+
83+
gen.dependOn(&b.addInstallArtifact(supergen, .{}).step);
6784
}
6885

6986
fn setupCheckStep(
@@ -106,8 +123,7 @@ fn setupTestStep(
106123

107124
const unit_tests = b.addTest(.{
108125
.root_module = superhtml,
109-
// .strip = true,
110-
// .filter = "if-else-loop",
126+
.filters = b.args orelse &.{},
111127
});
112128

113129
const run_unit_tests = b.addRunArtifact(unit_tests);

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
.hash = "tracy-0.0.0-4Xw-1pwwAABTfMgoDP1unCbZDZhJEfict7XCBGF6IdIn",
1414
},
1515
.lsp_kit = .{
16-
.url = "git+https://github.com/kristoff-it/lsp-kit?ref=zig-0.15#01c14e592d25dc57dfebba27b8bd2b4aa91c1140",
17-
.hash = "lsp_kit-0.1.0-bi_PL5YyCgA2QFEza6llr2Uy08QUQsWBu2wKvtr8tbLx",
16+
.url = "git+https://github.com/zigtools/lsp-kit#fe98e895ca3bd1b39965ab30f0f252f7b7e83ee6",
17+
.hash = "lsp_kit-0.1.0-bi_PLzAyCgClDh8_M0U9Q50ysdsQBuRuBTZfwg6rZPd6",
1818
},
1919
.scripty = .{
2020
.url = "git+https://github.com/kristoff-it/scripty#50dbab8945440089384f26ec165d870c29555247",

src/cli.zig

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ pub fn panic(
3131
) noreturn {
3232
if (lsp_mode) {
3333
std.log.err("\n{s}\n\n{?f}", .{ msg, trace });
34-
} else {
35-
std.debug.print("\n{s}\n\n{?f}", .{ msg, trace });
3634
}
35+
3736
blk: {
3837
const out: std.fs.File = if (!lsp_mode) std.fs.File.stderr() else logging.log_file orelse break :blk;
3938
var writer = out.writerStreaming(&.{});
@@ -43,14 +42,7 @@ pub fn panic(
4342
w.print("Unable to dump stack trace: debug info stripped\n", .{}) catch {};
4443
break :blk;
4544
}
46-
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
47-
w.print(
48-
"Unable to dump stack trace: Unable to open debug info: {s}\n",
49-
.{@errorName(err)},
50-
) catch {};
51-
break :blk;
52-
};
53-
std.debug.writeCurrentStackTrace(w, debug_info, .no_color, ret_addr) catch |err| {
45+
std.debug.writeCurrentStackTrace(.{ .first_address = ret_addr }, w, .no_color) catch |err| {
5446
w.print("Unable to dump stack trace: {t}\n", .{err}) catch {};
5547
break :blk;
5648
};

src/cli/check.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const super = @import("superhtml");
33

44
const FileType = enum { html, super };
55

6-
pub fn run(gpa: std.mem.Allocator, args: []const []const u8) !void {
6+
pub fn run(gpa: std.mem.Allocator, args: []const []const u8) !noreturn {
77
const cmd = Command.parse(args);
88
var any_error = false;
99
switch (cmd.mode) {
@@ -64,6 +64,7 @@ pub fn run(gpa: std.mem.Allocator, args: []const []const u8) !void {
6464
if (any_error) {
6565
std.process.exit(1);
6666
}
67+
std.process.exit(0);
6768
}
6869

6970
fn checkDir(
@@ -107,10 +108,9 @@ fn checkFile(
107108
const arena = arena_impl.allocator();
108109

109110
const in_bytes = try base_dir.readFileAllocOptions(
110-
arena,
111111
sub_path,
112-
super.max_size,
113-
null,
112+
arena,
113+
.limited(super.max_size),
114114
.of(u8),
115115
0,
116116
);

0 commit comments

Comments
 (0)