Skip to content

SIGSEV while zig build #24086

Open
Open
@furunkel

Description

@furunkel

Zig Version

0.14.1

Steps to Reproduce and Observed Behavior

I hit a segmentation fault during zig build. Unfortunately, isolating the issue is tricky, so I hope this is sufficient to locate the issue. I might be able to provide some specific details upon request. Note the debug trace was generated with the current bootstrap version.

error: thread 2896706 panic: reached unreachable code
Analyzing Analyzing 'src/main.zig'
      %334 = validate_struct_init_result_ty(%333) node_offset:192:15 to :192:44
      %335 = struct_init_field_type(%333, debug_serial) node_offset:192:34 to :192:42
      %336 = validate_ref_ty(%335) token_offset:192:34 to :192:35
    > %337 = struct_init([%335, %294]) node_offset:192:15 to :192:44
      %338 = break_inline(%333, %337)
    For full context, use the command
      zig ast-check -t src/main.zig

  in src/main.zig
    > %333 = field_call(nodiscard .auto, %331, "init", [
        {%334..%338},
      ]) node_offset:192:5 to :192:45

/home/user/build/zig-bootstrap/out/host/lib/zig/std/debug.zig:548:14: 0xa85f10d in assert (zig)
    if (!ok) unreachable; // assertion failure
             ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:2557:11: 0xb6f0e83 in errMsg__anon_368715 (zig)
    assert(src.offset != .unneeded);
          ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:26371:40: 0xb6f0c75 in requireRuntimeBlock (zig)
            const msg = try sema.errMsg(src, "unable to evaluate comptime expression", .{});
                                       ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:20107:33: 0xc0d9138 in structInitAnon__anon_584168 (zig)
    try sema.requireRuntimeBlock(block, LazySrcLoc.unneeded, block.src(.{ .init_elem = .{
                                ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:19654:35: 0xbbbfb78 in zirStructInit (zig)
        return sema.structInitAnon(block, src, inst, .typed_init, extra.data, extra.end, is_ref);
                                  ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:1264:68: 0xb6e18e1 in analyzeBodyInner (zig)
            .struct_init                  => try sema.zirStructInit(block, inst, false),
                                                                   ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:1062:30: 0xb2c3c3e in analyzeInlineBody (zig)
    if (sema.analyzeBodyInner(block, body)) |_| {
                             ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:1095:39: 0xaee63ae in resolveInlineBody (zig)
    return (try sema.analyzeInlineBody(block, body, break_target)) orelse .unreachable_value;
                                      ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:7574:65: 0xc145790 in analyzeArg (zig)
                const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst);
                                                                ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:7815:41: 0xbc4c238 in analyzeCall (zig)
        arg.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, callee, maybe_func_inst);
                                        ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:7275:43: 0xbb8caac in zirCall__anon_489917 (zig)
    const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
                                          ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:1183:62: 0xb6e0578 in analyzeBodyInner (zig)
            .field_call                   => try sema.zirCall(block, inst, .field),
                                                             ^
/home/user/build/zig-bootstrap/zig/src/Sema.zig:1044:26: 0xbb29a41 in analyzeFnBody (zig)
    sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                         ^
/home/user/build/zig-bootstrap/zig/src/Zcu/PerThread.zig:3017:23: 0xb68f63b in analyzeFnBodyInner (zig)
    sema.analyzeFnBody(&inner_block, fn_info.body) catch |err| switch (err) {
                      ^
/home/user/build/zig-bootstrap/zig/src/Zcu/PerThread.zig:1696:40: 0xb29ce07 in analyzeFuncBody (zig)
    var air = try pt.analyzeFnBodyInner(func_index);
                                       ^
/home/user/build/zig-bootstrap/zig/src/Zcu/PerThread.zig:1616:66: 0xaed07e3 in ensureFuncBodyUpToDate (zig)
    const ies_outdated, const new_failed = if (pt.analyzeFuncBody(func_index)) |result|
                                                                 ^
/home/user/build/zig-bootstrap/zig/src/Compilation.zig:4528:38: 0xacd3695 in processOneJob (zig)
            pt.ensureFuncBodyUpToDate(func) catch |err| switch (err) {
                                     ^
/home/user/build/zig-bootstrap/zig/src/Compilation.zig:4463:30: 0xab5f79b in performAllTheWorkInner (zig)
            try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job);
                             ^
/home/user/build/zig-bootstrap/zig/src/Compilation.zig:4174:36: 0xaa0d1dc in performAllTheWork (zig)
    try comp.performAllTheWorkInner(main_progress_node);
                                   ^
/home/user/build/zig-bootstrap/zig/src/Compilation.zig:2760:31: 0xaa07947 in update (zig)
    try comp.performAllTheWork(main_progress_node);
                              ^
/home/user/build/zig-bootstrap/zig/src/main.zig:4257:32: 0xaa80967 in serve (zig)
                try comp.update(main_progress_node);
                               ^
/home/user/build/zig-bootstrap/zig/src/main.zig:3681:22: 0xaaa25b6 in buildOutputType (zig)
            try serve(
                     ^
/home/user/build/zig-bootstrap/zig/src/main.zig:258:31: 0xa982a7a in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Exe });
                              ^
/home/user/build/zig-bootstrap/zig/src/main.zig:199:20: 0xa980c33 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/user/build/zig-bootstrap/out/host/lib/zig/std/start.zig:675:37: 0xa9807e1 in main (zig)
            const result = root.main() catch |err| {
                                    ^
../sysdeps/nptl/libc_start_call_main.h:58:16: 0x786956a2a1c9 in __libc_start_call_main (../sysdeps/x86/libc-start.c)
../csu/libc-start.c:360:3: 0x786956a2a28a in __libc_start_main_impl (../sysdeps/x86/libc-start.c)
???:?:?: 0x53783a4 in ??? (???)
???:?:?: 0x0 in ??? (???)

Expected Behavior

No crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions