Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incremental compilation fails on hello world test case, crash in updateZirRefs #20697

Closed
andrewrk opened this issue Jul 20, 2024 · 2 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. incremental compilation Problem occurs only when reusing compiler state.
Milestone

Comments

@andrewrk
Copy link
Member

Zig Version

0.14.0-dev.438+b5f3d1216

Steps to Reproduce and Observed Behavior

test case (available at test/incremental/hello):

#target=x86_64-linux
#update=initial version
#file=main.zig
const std = @import("std");
pub fn main() !void {
    try std.io.getStdOut().writeAll("good morning\n");
}
#expect_stdout="good morning\n"
#update=change the string
#file=main.zig
const std = @import("std");
pub fn main() !void {
    try std.io.getStdOut().writeAll("おはようございます\n");
}
#expect_stdout="おはようございます\n"
$ stage3/bin/zig run ../tools/incr-check.zig -- stage4/bin/zig ../test/incremental/hello 
error: update 'change the string' failed:
thread 619922 panic: reached unreachable code
/home/andy/dev/zig/lib/std/debug.zig:404:14: 0x18c18ad in assert (zig)
    if (!ok) unreachable; // assertion failure
             ^
/home/andy/dev/zig/src/InternPool.zig:698:27: 0x1f94180 in view (zig)
                    assert(capacity > 0); // optimizes `MultiArrayList.Slice.items`
                          ^
/home/andy/dev/zig/src/Zcu/PerThread.zig:373:37: 0x1d3d9ea in updateZirRefs (zig)
        for (tracked_insts_list.view().items(.@"0"), 0..) |*tracked_inst, tracked_inst_unwrapped_index| {
                                    ^
/home/andy/dev/zig/src/Compilation.zig:3602:33: 0x1b0f249 in performAllTheWorkInner (zig)
            try pt.updateZirRefs();
                                ^
/home/andy/dev/zig/src/Compilation.zig:3496:36: 0x19d2b53 in performAllTheWork (zig)
    try comp.performAllTheWorkInner(main_progress_node);
                                   ^
/home/andy/dev/zig/src/Compilation.zig:2231:31: 0x19cf318 in update (zig)
    try comp.performAllTheWork(main_progress_node);
                              ^
/home/andy/dev/zig/src/main.zig:4104:32: 0x1a13cf3 in serve (zig)
                try comp.update(main_progress_node);
                               ^
/home/andy/dev/zig/src/main.zig:3399:22: 0x1a316c6 in buildOutputType (zig)
            try serve(
                     ^
/home/andy/dev/zig/src/main.zig:263:31: 0x18c387a in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Exe });
                              ^
/home/andy/dev/zig/src/main.zig:209:20: 0x18bf9fa in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/andy/dev/zig/lib/std/start.zig:532:37: 0x18bf0f5 in posixCallMainAndExit (zig)
            const result = root.main() catch |err| {
                                    ^
/home/andy/dev/zig/lib/std/start.zig:277:5: 0x18bec11 in _start (zig)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0xc in ??? (???)
Unwind information for `???:0xc` was not available, trace may be incomplete

Expected Behavior

Passing test case.

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. incremental compilation Problem occurs only when reusing compiler state. labels Jul 20, 2024
@andrewrk andrewrk added this to the 0.14.0 milestone Jul 20, 2024
@mlugg
Copy link
Member

mlugg commented Jul 20, 2024

you know shit's getting serious when we have an issue label

mlugg added a commit to mlugg/zig that referenced this issue Aug 12, 2024
This fixes the regressions introduced by ziglang#20964. It also cleans up the
"outdated file root" mechanism by virtue of deleting it. We now detect
outdated file roots just after updating ZIR refs, and re-scan their
namespaces.

@jacobly0, this deletes some asserts in `InternPool` which didn't look
appropriate to me, in order to deal with ziglang#20697.
@mlugg
Copy link
Member

mlugg commented Aug 23, 2024

This now hits an ELF linker crash which is tracked by #21165.

@mlugg mlugg closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. incremental compilation Problem occurs only when reusing compiler state.
Projects
None yet
Development

No branches or pull requests

2 participants