-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.15.0-dev.382+6a7ca4b8b
Steps to Reproduce and Observed Behavior
do zig init
modify src/main.zig
to be:
pub fn main() !void {}
test "fuzz example1" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
test "fuzz example2" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
test "fuzz example3" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
test "fuzz example4" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
test "fuzz example5" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
test "fuzz example6" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
test "fuzz example7" {
const Context = struct {
fn testOne(context: @This(), input: []const u8) anyerror!void {
_ = context;
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
try std.testing.expect(!std.mem.eql(u8, to_find, input));
}
};
try std.testing.fuzz(Context{}, Context.testOne, .{});
}
const std = @import("std");
// Some long string. Interestingly `"abcdef" ** 10` did not repro this bug.
const to_find = "asdfasd;fkja;sdklfjasdf asd fasdfa;sd as asdfa d erjjwhasdnfasd fasd fljkhasd;fas;df asdf asd fas dfasd fas dfa sdf asdf asdfhalsjkdhflkajshdfl jasd flas dflkjahs dlkjfhas dfals dfljah sdlfkjha sldjkfh alsdjkfh laksjdh fklajsdh flkjahs dlfkjah sdlkfjh asldjkfh alsjkdh l";
run zig build test --fuzz
Observe:
...
Segmentation fault at address 0x0
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/fuzzer.zig:589:35: 0x1194190 in start (fuzzer)
@memcpy(l.items[old_len..][0..items.len], items);
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/fuzzer.zig:460:17: 0x119684f in fuzzer_start (fuzzer)
fuzzer.start() catch |err| oom(err);
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/compiler/test_runner.zig:414:21: 0x105fcc8 in fuzz__anon_435 (test)
fuzzer_start(&global.fuzzer_one);
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/std/testing.zig:1176:32: 0x105fb34 in test.fuzz example1 (test)
return @import("root").fuzz(context, testOne, options);
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/compiler/test_runner.zig:159:29: 0x114d55b in mainServer (test)
test_fn.func() catch |err| switch (err) {
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/compiler/test_runner.zig:60:26: 0x1146c95 in main (test)
return mainServer() catch @panic("internal test runner failure");
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/std/start.zig:662:22: 0x1145e10 in posixCallMainAndExit (test)
root.main();
^
/nix/store/r2nhic5aza37vcq5x332nam503y28fnq-zig-0.15.0-dev.382+6a7ca4b8b/lib/std/start.zig:282:5: 0x11459dd in _start (test)
asm volatile (switch (native_arch) {
^
???:?:?: 0x0 in ??? (???)
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: the following command terminated unexpectedly:
/tmp/huh/.zig-cache/o/990eaf467b0343a37d3be58898e2faeb/test --seed=0x4908bb1c --cache-dir=/tmp/huh/.zig-cache --listen=-
error: all fuzz workers crashed
To reproduce again, remove cache.
Expected Behavior
No segfault
ozgrakkurt, ivanstepanovftw and ScoreUnder
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior