-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Compiling fuzz tests with -OReleaseSafe is the primary use case - you want to quickly test as many inputs as possible, while still testing all the properties are being upheld with each run.
Unfortunately right now this breaks the entry points feature, causing the entry point URL to point somewhere into compiler_rt, like /home/andy/local/lib/zig/compiler_rt/udivmodei4.zig:128:61. That's not helpful at all.
Combined with #20983 not being implemented yet, it makes the fuzzing web interface completely unusable.
Running dump-cov, I think I see the issue:
andy@bark ~/t/abc> zig-dev run ~/dev/zig/tools/dump-cov.zig -- .zig-cache/o/36d239a9859a75bd1fc17c8ce0d164ea/test .zig-cache/v/cc4f02f7d909bcd9
thread 59195 panic: reached unreachable code
/home/andy/dev/zig/lib/std/debug.zig:399:14: 0x104276d in assert (dump-cov)
if (!ok) unreachable; // assertion failure
^
/home/andy/dev/zig/tools/dump-cov.zig:54:11: 0x1041131 in main (dump-cov)
assert(std.sort.isSorted(usize, pcs, {}, std.sort.asc(usize)));
^
/home/andy/dev/zig/lib/std/start.zig:623:37: 0x103d8ff in posixCallMainAndExit (dump-cov)
const result = root.main() catch |err| {
^
/home/andy/dev/zig/lib/std/start.zig:240:5: 0x103d4ed in _start (dump-cov)
asm volatile (switch (native_arch) {
^
???:?:?: 0x2 in ??? (???)
Unwind information for `???:0x2` was not available, trace may be incomplete
fish: Job 1, 'zig-dev run ~/dev/zig/tools/dum…' terminated by signal SIGABRT (Abort)
This assertion is not present in the fuzzer web server, so it was just getting bogus data. It can therefore likely be solved by sorting the PCs provided by LLVM's sancov implementation before using them. That assumption is here:
zig/lib/std/Build/Fuzz/WebServer.zig
Lines 634 to 637 in 7a7421c
| const pcs = std.mem.bytesAsSlice(usize, pcs_bytes); | |
| const source_locations = try gpa.alloc(Coverage.SourceLocation, pcs.len); | |
| errdefer gpa.free(source_locations); | |
| debug_info.resolveAddresses(gpa, pcs, source_locations) catch |err| { |
and
zig/lib/std/Build/Fuzz/WebServer.zig
Lines 653 to 658 in 7a7421c
| const pcs: []const usize = @alignCast(std.mem.bytesAsSlice(usize, pcs_bytes)); | |
| const index = std.sort.upperBound(usize, pcs, addr, struct { | |
| fn order(context: usize, item: usize) std.math.Order { | |
| return std.math.order(item, context); | |
| } | |
| }.order); |