ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
35.02k stars 2.56k forks source link

zig test crashes with no error #15018

Open RossComputerGuy opened 1 year ago

RossComputerGuy commented 1 year ago

Zig Version

0.11.0-dev.2160+49d37e2d1

Steps to Reproduce and Observed Behavior

Recently, my ability to generate documentation thru a test has broke with the new parallel builds update.

Link to relevant code

With zig build:

zig test neutron-docs Debug x86_64-linux-gnu: error: thread 1414826 panic: attempt to unwrap error
Unable to dump stack trace: debug info stripped

zig test neutron-docs Debug x86_64-linux-gnu: error: the following command terminated unexpectedly:
/nix/store/5nnciv3g8knn7nl7isdhbwv9qm1k0i4x-zig-0.11.0-dev.2160+49d37e2d1/bin/zig test /home/ross/ExpidusOS/neutron/src/neutron.zig /home/ross/ExpidusOS/neutron/zig-cache/o/640e97b63b081c18e5e48fcfdbb469d0/libwayland-server.so.1.21.0 -rpath /home/ross/ExpidusOS/neutron/zig-cache/o/640e97b63b081c18e5e48fcfdbb469d0 /home/ross/ExpidusOS/neutron/zig-cache/o/ba98135b93a6d5b7ebb0bf11ce64f1d4/libwlroots.so.0.16.2 -rpath /home/ross/ExpidusOS/neutron/zig-cache/o/ba98135b93a6d5b7ebb0bf11ce64f1d4 -lc -femit-docs=/home/ross/ExpidusOS/neutron/outputs/out/docs --cache-dir /home/ross/ExpidusOS/neutron/zig-cache --global-cache-dir /home/ross/.cache/zig --name neutron-docs -target x86_64-linux-gnu -mcpu x86_64 --dynamic-linker /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/ld-linux-x86-64.so.2 -I /home/ross/ExpidusOS/neutron/vendor/os-specific/linux/libs/wlroots/include -I /home/ross/ExpidusOS/neutron/zig-cache/o/95369d374a97a9b094cb4fd5d49a122f/ -I /home/ross/ExpidusOS/neutron/zig-cache/o/f9c90e00dcfb0fe4f69c72b433dceb6d/ --enable-cache --listen=-

Running the command directly (without listen):

thread 1419471 panic: attempt to unwrap error
Unable to dump stack trace: debug info stripped
Aborted (コアダンプ)

Expected Behavior

Zig should throw an error of what actually went wrong or it should work just fine like it did in the past.

andrewrk commented 1 year ago

It would be helpful to see output of the crash with a debug build of the compiler.

RossComputerGuy commented 1 year ago

Yeah, I'm trying to get a debug compiler build but I keep on running into issues. Tried both directly with CMake and I end up with things being named wrong in C++ code. Trying from a pre-built and I get missing headers.

nektro commented 1 year ago

Trying from a pre-built and I get missing headers.

this is a race condition in your build script

crash log

zig test neutron-docs Debug native: error: thread 647831 panic: attempt to unwrap error: PackageNotFound
/home/meghan/src/zig/src/Module.zig:4842:9: 0xd19adc in importFile (zig)
        return error.PackageNotFound;
        ^
/home/meghan/src/zig/src/Autodoc.zig:933:71: 0xae6cf5 in walkInstruction (zig)
            const new_file = self.module.importFile(file, path) catch unreachable;
                                                                      ^
/home/meghan/src/zig/src/Autodoc.zig:4346:36: 0xd1ce86 in walkRef (zig)
        return self.walkInstruction(file, parent_scope, parent_src, zir_index, need_type);
                                   ^
/home/meghan/src/zig/src/Autodoc.zig:2122:21: 0xaf43f1 in walkInstruction (zig)
                    return res;
                    ^
/home/meghan/src/zig/src/Autodoc.zig:3210:53: 0xd27dc4 in walkDecls (zig)
        const walk_result = try self.walkInstruction(file, scope, decl_src, value_index, true);
                                                    ^
/home/meghan/src/zig/src/Autodoc.zig:2910:53: 0xafd273 in walkInstruction (zig)
                    extra_index = try self.walkDecls(
                                                    ^
/home/meghan/src/zig/src/Autodoc.zig:232:61: 0xae4022 in generateZirData (zig)
    _ = try self.walkInstruction(file, &root_scope, .{}, Zir.main_struct_inst, false);
                                                            ^
/home/meghan/src/zig/src/Compilation.zig:2054:44: 0xb0957e in update (zig)
                try autodoc.generateZirData();
                                           ^
/home/meghan/src/zig/src/main.zig:3499:36: 0xb35528 in serve (zig)
                    try comp.update(main_progress_node);
                                   ^
/home/meghan/src/zig/src/main.zig:3305:31: 0x9d49eb in buildOutputType (zig)
                test_exec_args.items,
                              ^
/home/meghan/src/zig/src/main.zig:273:31: 0x9a82c4 in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .zig_test);
                              ^
/home/meghan/src/zig/src/main.zig:211:20: 0x9a7775 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/meghan/src/zig/lib/std/start.zig:617:37: 0x9a9e5c in main (zig)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7efd78b1224d in ??? (???)
???:?:?: 0x7fffb3d34318 in ??? (???)
RossComputerGuy commented 1 year ago

Oh thanks for getting me that, not sure what the issue exactly is or how to fix it.

Edit: I forgot to run addModule for the dependencies and that fixed it. Maybe it should throw an error when a module is needed but not added?