| ... | @@ -686,7 +686,7 @@ const Fuzzer = struct { | ... | @@ -686,7 +686,7 @@ const Fuzzer = struct { |
| 686 | const len = mem.readInt(u32, f.mmap_input.mmap.memory[0..4], .little); | 686 | const len = mem.readInt(u32, f.mmap_input.mmap.memory[0..4], .little); |
| 687 | if (len < f.mmap_input.mmap.memory[4..].len) { | 687 | if (len < f.mmap_input.mmap.memory[4..].len) { |
| 688 | f.mmap_input.len = len; | 688 | f.mmap_input.len = len; |
| 689 | f.runBytes(f.mmap_input.inputSlice(), .bytes_dry); | 689 | _ = f.runBytes(f.mmap_input.inputSlice(), .bytes_dry); |
| 690 | f.mmap_input.clearRetainingCapacity(); | 690 | f.mmap_input.clearRetainingCapacity(); |
| 691 | } | 691 | } |
| 692 | } | 692 | } |
| ... | @@ -761,12 +761,13 @@ const Fuzzer = struct { | ... | @@ -761,12 +761,13 @@ const Fuzzer = struct { |
| 761 | return fresh; | 761 | return fresh; |
| 762 | } | 762 | } |
| 763 | | 763 | |
| 764 | fn runBytes(f: *Fuzzer, bytes: []const u8, mode: Input.Index) void { | 764 | /// Returns if `error.SkipZigTest` was indicated |
| | 765 | fn runBytes(f: *Fuzzer, bytes: []const u8, mode: Input.Index) bool { |
| 765 | assert(mode == .bytes_dry or mode == .bytes_fresh); | 766 | assert(mode == .bytes_dry or mode == .bytes_fresh); |
| 766 | | 767 | |
| 767 | f.bytes_input = .{ .in = bytes }; | 768 | f.bytes_input = .{ .in = bytes }; |
| 768 | f.corpus_pos = mode; | 769 | f.corpus_pos = mode; |
| 769 | f.run(0); // 0 since `f.uid_data` is unused | 770 | return f.run(0); // 0 since `f.uid_data` is unused |
| 770 | } | 771 | } |
| 771 | | 772 | |
| 772 | fn updateSeenPcs(f: *Fuzzer) void { | 773 | fn updateSeenPcs(f: *Fuzzer) void { |
| ... | @@ -871,7 +872,11 @@ const Fuzzer = struct { | ... | @@ -871,7 +872,11 @@ const Fuzzer = struct { |
| 871 | | 872 | |
| 872 | fn newInput(f: *Fuzzer, modify_fs_corpus: bool) void { | 873 | fn newInput(f: *Fuzzer, modify_fs_corpus: bool) void { |
| 873 | const bytes = f.mmap_input.inputSlice(); | 874 | const bytes = f.mmap_input.inputSlice(); |
| 874 | f.runBytes(bytes, .bytes_fresh); | 875 | // `error.SkipZigTest` here can be from one of these causes: |
| | 876 | // * The test has changed and a previous corpus input is being used |
| | 877 | // * An input provided by the test results in it |
| | 878 | // * The test is non-deterministic |
| | 879 | if (f.runBytes(bytes, .bytes_fresh)) return; |
| 875 | f.req_values = f.input_builder.total_ints + f.input_builder.total_bytes; | 880 | f.req_values = f.input_builder.total_ints + f.input_builder.total_bytes; |
| 876 | f.req_bytes = @intCast(f.input_builder.bytes_table.items.len); | 881 | f.req_bytes = @intCast(f.input_builder.bytes_table.items.len); |
| 877 | var input = f.input_builder.build(); | 882 | var input = f.input_builder.build(); |
| ... | @@ -1005,15 +1010,17 @@ const Fuzzer = struct { | ... | @@ -1005,15 +1010,17 @@ const Fuzzer = struct { |
| 1005 | panic("failed to write corpus file '{s}': {t}", .{ name, e }); | 1010 | panic("failed to write corpus file '{s}': {t}", .{ name, e }); |
| 1006 | } | 1011 | } |
| 1007 | | 1012 | |
| 1008 | fn run(f: *Fuzzer, input_uids: usize) void { | 1013 | /// Returns if `error.SkipZigTest` was indicated |
| | 1014 | fn run(f: *Fuzzer, input_uids: usize) bool { |
| 1009 | @memset(exec.pc_counters, 0); | 1015 | @memset(exec.pc_counters, 0); |
| 1010 | f.uid_data_i.items.len = input_uids; | 1016 | f.uid_data_i.items.len = input_uids; |
| 1011 | @memset(f.uid_data_i.items, 0); | 1017 | @memset(f.uid_data_i.items, 0); |
| 1012 | f.req_values = 0; | 1018 | f.req_values = 0; |
| 1013 | f.req_bytes = 0; | 1019 | f.req_bytes = 0; |
| 1014 | | 1020 | |
| 1015 | f.test_one(); | 1021 | const skip = f.test_one(); |
| 1016 | _ = @atomicRmw(usize, &exec.seenPcsHeader().n_runs, .Add, 1, .monotonic); | 1022 | _ = @atomicRmw(usize, &exec.seenPcsHeader().n_runs, .Add, 1, .monotonic); |
| | 1023 | return skip; |
| 1017 | } | 1024 | } |
| 1018 | | 1025 | |
| 1019 | /// Returns a number of mutations to perform from 1-4 | 1026 | /// Returns a number of mutations to perform from 1-4 |
| ... | @@ -1085,8 +1092,8 @@ const Fuzzer = struct { | ... | @@ -1085,8 +1092,8 @@ const Fuzzer = struct { |
| 1085 | i.* = data.order[order_i]; | 1092 | i.* = data.order[order_i]; |
| 1086 | }; | 1093 | }; |
| 1087 | | 1094 | |
| 1088 | f.run(data.uid_slices.entries.len); | 1095 | const skip = f.run(data.uid_slices.entries.len); |
| 1089 | if (f.isFresh()) { | 1096 | if (!skip and f.isFresh()) { |
| 1090 | @branchHint(.unlikely); | 1097 | @branchHint(.unlikely); |
| 1091 | | 1098 | |
| 1092 | _ = @atomicRmw(usize, &exec.seenPcsHeader().unique_runs, .Add, 1, .monotonic); | 1099 | _ = @atomicRmw(usize, &exec.seenPcsHeader().unique_runs, .Add, 1, .monotonic); |