Skip to content

Trivial fuzz testing fails with Fuzz/WebServer.zig error #24222

Closed as duplicate of#23423
@RetroDev256

Description

@RetroDev256

Zig Version

0.15.0-dev.847+850655f06

Steps to Reproduce and Observed Behavior

  1. Create a new zig project using zig init
  2. Drop this in main.zig:
const std = @import("std");

fn toFuzz(_: void, input: []const u8) !void {
    if (std.mem.eql(u8, input, "Hello, World!\n")) {
        return error.SomeUnexpectedError;
    }
}

test "fuzz some code" {
    try std.testing.fuzz({}, toFuzz, .{});
}
  1. Run zig build test --fuzz
  2. Observe this output:
retrodev@lime ~/repos/Zig/hello_world $ zig build test --fuzz
info: web interface listening at http://127.0.0.1:40173/
info: hint: pass --port 40173 to use this same port next time
thread 28501 panic: start index 1 is larger than end index 0
/home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/lib/std/Build/Fuzz/WebServer.zig:685:17: 0x14162ff in addEntryPoint (std.zig)
        for (pcs[1..], 1..) |elem_addr, i| {
                ^
/home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/lib/std/Build/Fuzz/WebServer.zig:566:56: 0x1376617 in coverageRun (std.zig)
            .entry_point => |entry_point| addEntryPoint(ws, entry_point.coverage_id, entry_point.addr) catch |err| switch (err) {
                                                       ^
/home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/lib/std/Thread.zig:510:13: 0x12fad47 in callFn__anon_74160 (std.zig)
            @call(.auto, f, args);
            ^
/home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/lib/std/Thread.zig:1403:30: 0x1285ef0 in entryFn (std.zig)
                return callFn(f, self.fn_args);
                             ^
/home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/lib/std/os/linux/x86_64.zig:126:5: 0x1247a59 in clone (std.zig)
    asm volatile (
    ^
???:?:?: 0x0 in ??? (???)
error: the following build command crashed:
.zig-cache/o/782496cac440ab2e47c905e17fe48eb3/build /home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/zig /home/retrodev/repos/Zig/.zig/0.15.0-dev.847+850655f06/files/lib /home/retrodev/repos/Zig/hello_world .zig-cache /home/retrodev/.cache/zig --seed 0x308254 -Z91428b6fcec4f69d test --fuzz

Expected Behavior

I expect the fuzz testing to continue as normal. I expect the fuzzer to not crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfuzzing

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions