Hello.
I am trying to set up fuzzing for tatfi, and I have been trying to use zig-afl-kit. And it like an obstacle course, every time I figure out something a new error pops up !
This is the build.zig portion
fn set_up_fuzzing(
b: *std.Build,
mod: *std.Build.Module,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
) void {
const afl = @import("afl_kit");
const fuzz = b.step("fuzz", "Generate an instrumented executable for AFL++");
const fuzz_mod = b.createModule(.{
.root_source_file = b.path("src/fuzz_glyph_index.zig"),
.target = target,
.optimize = .Debug,
});
fuzz_mod.addImport("tatfi", mod);
const afl_obj = b.addObject(.{
.name = "my_fuzz_obj",
.root_module = fuzz_mod,
});
afl_obj.root_module.stack_check = false; // not linking with compiler-rt
afl_obj.root_module.link_libc = true; // afl runtime depends on libc
afl_obj.root_module.fuzz = true;
if (afl.addInstrumentedExe(
b,
target,
optimize,
&.{"/opt/homebrew/opt/llvm/bin"},
false,
afl_obj,
&.{},
)) |afl_fuzz| fuzz.dependOn(&b.addInstallBinFile(afl_fuzz, "myfuzz-afl").step);
}
Then I am hit with a giant ball of errors
Build Summary: 55/86 steps succeeded; 12 failed
fuzz transitive failure
ββ install generated to myfuzz-afl transitive failure
ββ run .zig-cache/i/a3d10ad363c9d634b2e9fcafebef5868/bin/afl-cc (my_fuzz_obj) transitive failure
ββ llvm_exes transitive failure
ββ install afl-cc transitive failure
β ββ llvm_libs transitive failure
β ββ install afl-llvm-dict2file transitive failure
β β ββ compile lib afl-llvm-dict2file Debug native 2 errors
β ββ install afl-llvm-pass transitive failure
β β ββ compile lib afl-llvm-pass Debug native 2 errors
β ββ install cmplog-instructions-pass transitive failure
β β ββ compile lib cmplog-instructions-pass Debug native 2 errors
β ββ install cmplog-routines-pass transitive failure
β β ββ compile lib cmplog-routines-pass Debug native 2 errors
β ββ install cmplog-switches-pass transitive failure
β β ββ compile lib cmplog-switches-pass Debug native 2 errors
β ββ install compare-transform-pass transitive failure
β β ββ compile lib compare-transform-pass Debug native 2 errors
β ββ install injection-pass transitive failure
β β ββ compile lib injection-pass Debug native 2 errors
β ββ install SanitizerCoveragePCGUARD transitive failure
β β ββ compile lib SanitizerCoveragePCGUARD Debug native 2 errors
β ββ install split-compares-pass transitive failure
β β ββ compile lib split-compares-pass Debug native 2 errors
β ββ install split-switches-pass transitive failure
β β ββ compile lib split-switches-pass Debug native 2 errors
β ββ install afl-llvm-lto-instrumentlist transitive failure
β β ββ compile lib afl-llvm-lto-instrumentlist Debug native 2 errors
β ββ install SanitizerCoverageLTO transitive failure
β ββ compile lib SanitizerCoverageLTO Debug native 2 errors
ββ install afl-ld-lto transitive failure
ββ llvm_libs (+12 more reused dependencies)
Any ideas on how to proceed? I am on M2 MacBook Air.
this is fuzz_glyph_index.zig file
const std = @import("std");
const ttf = @import("tatfi");
const CHARS: []const u21 = &.{ '\u{0}', 'A', 'Π€', '0', '\u{D7FF}', '\u{10FFFF}' };
export fn zig_fuzz_init() void {}
export fn zig_fuzz_test(buf: [*]u8, len: isize) void {
const data = buf[0..@intCast(len)];
const face = ttf.Face.parse(data, 0) catch return;
// how do i know this doesnt get optimized out?
for (CHARS) |char|
_ = face.glyph_index(char);
}