| ... | ... | @@ -594,6 +594,21 @@ const Fuzzer = struct { |
| 594 | 594 | b.smithed_len = 4; |
| 595 | 595 | return input; |
| 596 | 596 | } |
| 597 | |
| 598 | pub fn reset(b: *Builder) void { |
| 599 | const uid_slices = b.uid_slices.entries.slice(); |
| 600 | for (uid_slices.items(.key), uid_slices.items(.value)) |uid, *uid_data| { |
| 601 | switch (uid.kind) { |
| 602 | .int => uid_data.ints.deinit(gpa), |
| 603 | .bytes => uid_data.bytes.deinit(gpa), |
| 604 | } |
| 605 | } |
| 606 | b.uid_slices.clearRetainingCapacity(); |
| 607 | b.total_ints = 0; |
| 608 | b.total_bytes = 0; |
| 609 | b.weighted_len = 0; |
| 610 | b.smithed_len = 4; |
| 611 | } |
| 597 | 612 | }; |
| 598 | 613 | }; |
| 599 | 614 | |
| ... | ... | @@ -876,7 +891,14 @@ const Fuzzer = struct { |
| 876 | 891 | // * The test has changed and a previous corpus input is being used |
| 877 | 892 | // * An input provided by the test results in it |
| 878 | 893 | // * The test is non-deterministic |
| 879 | | if (f.runBytes(bytes, .bytes_fresh)) return; |
| 894 | if (f.runBytes(bytes, .bytes_fresh) and |
| 895 | modify_fs_corpus // The input is not from the filesystem. |
| 896 | // This is required to ensure the filesystem and process corpus are the same. |
| 897 | ) { |
| 898 | f.input_builder.reset(); |
| 899 | f.corpus_pos = @enumFromInt(0); |
| 900 | return; |
| 901 | } |
| 880 | 902 | f.req_values = f.input_builder.total_ints + f.input_builder.total_bytes; |
| 881 | 903 | f.req_bytes = @intCast(f.input_builder.bytes_table.items.len); |
| 882 | 904 | var input = f.input_builder.build(); |
| ... | ... | @@ -1859,7 +1881,6 @@ const MemoryMappedInput = struct { |
| 1859 | 1881 | /// Invalidates item pointers if more space is required. |
| 1860 | 1882 | pub fn appendLittleInt(l: *MemoryMappedInput, T: type, x: T) void { |
| 1861 | 1883 | l.ensureUnusedCapacity(@sizeOf(T)); |
| 1862 | | //std.log.debug("{} {} {}", .{ l.writeSlice().len, l.len, @sizeOf(T) }); |
| 1863 | 1884 | l.writeSlice()[4 + l.len ..][0..@sizeOf(T)].* = @bitCast(mem.nativeToLittle(T, x)); |
| 1864 | 1885 | l.len += @sizeOf(T); |
| 1865 | 1886 | l.writeLen(); |