octopus-foundation / gremlin.zig

A zero-dependency Google Protocol Buffers implementation in pure Zig. Single allocation encode and lazy decode
MIT License
128 stars 3 forks source link

Codegen fails with panic: unreachable #2

Open guacs opened 1 week ago

guacs commented 1 week ago

The codegen fails with the following error:

/home/guacs/.zvm/master/lib/std/posix.zig:5157:18: 0x161b949 in lseek_SET (build)
        .BADF => unreachable, // always a race condition
                 ^
/home/guacs/.zvm/master/lib/std/fs/Dir.zig:361:40: 0x159bb44 in nextLinux (build)
                        posix.lseek_SET(self.dir.fd, 0) catch unreachable; // EBADF here likely means that the Dir was not opened with iteration permissions
                                       ^
/home/guacs/.zvm/master/lib/std/fs/Dir.zig:345:34: 0x1526397 in next (build)
            return self.nextLinux() catch |err| switch (err) {
                                 ^
/home/guacs/.zvm/master/lib/std/fs/Dir.zig:680:30: 0x15257b6 in next (build)
            if (top.iter.next() catch |err| {
                             ^
/home/guacs/.cache/zig/p/1220a59f39767373cb41cd234679b99f92cbc0d55ade64cd01d3c8c1b90c1183fdaa/src/parser/fs/paths.zig:37:27: 0x15269cd in findProtoFiles (build)
    while (try walker.next()) |entry| {
                          ^
/home/guacs/.cache/zig/p/1220a59f39767373cb41cd234679b99f92cbc0d55ade64cd01d3c8c1b90c1183fdaa/src/parser/parser.zig:102:49: 0x1529cee in parse (build)
    const proto_files = try paths.findProtoFiles(allocator, base_path);
                                                ^
/home/guacs/.cache/zig/p/1220a59f39767373cb41cd234679b99f92cbc0d55ade64cd01d3c8c1b90c1183fdaa/src/codegen/gen.zig:103:44: 0x154b577 in generateProtobuf (build)
    const parsed = try gremlin_parser.parse(allocator, proto_root);
                                           ^
/home/guacs/.cache/zig/p/1220a59f39767373cb41cd234679b99f92cbc0d55ade64cd01d3c8c1b90c1183fdaa/step.zig:61:21: 0x14bdf52 in make (build)
    generateProtobuf(
                    ^
/home/guacs/.zvm/master/lib/std/Build/Step.zig:231:13: 0x1484817 in make (build)
    s.makeFn(s, options) catch |err| switch (err) {
            ^
/home/guacs/.zvm/master/lib/compiler/build_runner.zig:1097:31: 0x14401c0 in workerMakeOneStep (build)
    const make_result = s.make(.{
                              ^
/home/guacs/.zvm/master/lib/std/Thread/Pool.zig:115:39: 0x1440b91 in runFn (build)
            @call(.auto, func, closure.arguments);
                                      ^
/home/guacs/.zvm/master/lib/std/Thread/Pool.zig:291:32: 0x14c6805 in worker (build)
            run_node.data.runFn(&run_node.data, id);
                               ^
/home/guacs/.zvm/master/lib/std/Thread.zig:486:13: 0x148347d in callFn__anon_55486 (build)
            @call(.auto, f, args);
            ^
/home/guacs/.zvm/master/lib/std/Thread.zig:1373:30: 0x143f897 in entryFn (build)
                return callFn(f, self.fn_args);
                             ^
/home/guacs/.zvm/master/lib/std/os/linux/x86_64.zig:104:5: 0x1483511 in clone (build)
    asm volatile (
batsuev commented 1 week ago

Thanks for reporting this! Looks like there are inaccessible files - we should handle them more gracefully by skipping them instead of hitting the unreachable. I'll update the code to do this.

guacs commented 1 week ago

I thought the solution was to add .iterate = true to the open directory options when opening the directory?