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

stage2/lllvm: panic in lowering maxInt(u32) slice end #14628

Closed
nektro opened this issue Feb 12, 2023 · 4 comments
Closed

stage2/lllvm: panic in lowering maxInt(u32) slice end #14628

nektro opened this issue Feb 12, 2023 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@nektro
Copy link
Contributor

nektro commented Feb 12, 2023

Zig Version

0.11.0-dev.1584+9ccd8ed0a

Steps to Reproduce and Observed Behavior

const std = @import("std");
const arbitrary_max = std.math.maxInt(u32);

test {
    const a = [_]u8{0};
    const b = &a;
    const c: [*]const u8 = b;
    const d = c[0..arbitrary_max];
    _ = d;
}
thread 3990561 panic: integer cast truncated bits
/home/meghan/src/zig/src/codegen/llvm.zig:1724:48: 0xf1eedd in lowerDebugTypeImpl (zig)
                    @intCast(c_int, ty.arrayLen()),
                                               ^
/home/meghan/src/zig/src/codegen/llvm.zig:1436:36: 0xcb30fd in lowerDebugType (zig)
        return o.lowerDebugTypeImpl(entry, resolve, null);
                                   ^
/home/meghan/src/zig/src/codegen/llvm.zig:1684:65: 0xf1e499 in lowerDebugTypeImpl (zig)
                const elem_di_ty = try o.lowerDebugType(ptr_info.pointee_type, .fwd);
                                                                ^
/home/meghan/src/zig/src/codegen/llvm.zig:1436:36: 0xcb30fd in lowerDebugType (zig)
        return o.lowerDebugTypeImpl(entry, resolve, null);
                                   ^
/home/meghan/src/zig/src/codegen/llvm.zig:1598:59: 0xf1d77b in lowerDebugTypeImpl (zig)
                    const ptr_di_ty = try o.lowerDebugType(bland_ptr_ty, resolve);
                                                          ^
/home/meghan/src/zig/src/codegen/llvm.zig:1436:36: 0xcb30fd in lowerDebugType (zig)
        return o.lowerDebugTypeImpl(entry, resolve, null);
                                   ^
/home/meghan/src/zig/src/codegen/llvm.zig:6175:46: 0x169a7f5 in airDbgVarVal (zig)
            try self.dg.object.lowerDebugType(operand_ty, .full),
                                             ^
/home/meghan/src/zig/src/codegen/llvm.zig:4698:54: 0x114b9f5 in genBody (zig)
                .dbg_var_val => try self.airDbgVarVal(inst),
                                                     ^
/home/meghan/src/zig/src/codegen/llvm.zig:1200:35: 0x11436f6 in updateFunc (zig)
        fg.genBody(air.getMainBody()) catch |err| switch (err) {
                                  ^
/home/meghan/src/zig/src/link/Elf.zig:2451:74: 0x114c34e in updateFunc (zig)
        if (self.llvm_object) |llvm_object| return llvm_object.updateFunc(module, func, air, liveness);
                                                                         ^
/home/meghan/src/zig/src/link.zig:539:77: 0xe9e1de in updateFunc (zig)
            .elf   => return @fieldParentPtr(Elf,   "base", base).updateFunc(module, func, air, liveness),
                                                                            ^
/home/meghan/src/zig/src/Module.zig:4245:37: 0xc5863d in ensureFuncBodyAnalyzed (zig)
            comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) {
                                    ^
/home/meghan/src/zig/src/Compilation.zig:3217:42: 0xc55ca5 in processOneJob (zig)
            module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
                                         ^
/home/meghan/src/zig/src/Compilation.zig:3155:30: 0xaaf9e7 in performAllTheWork (zig)
            try processOneJob(comp, work_item);
                             ^
/home/meghan/src/zig/src/Compilation.zig:2405:31: 0xaaa68c in update (zig)
    try comp.performAllTheWork(main_progress_node);
                              ^
/home/meghan/src/zig/src/main.zig:3525:20: 0xad2e1d in updateModule (zig)
    try comp.update();
                   ^
/home/meghan/src/zig/src/main.zig:3188:17: 0x9b6a30 in buildOutputType (zig)
    updateModule(gpa, comp, hook) catch |err| switch (err) {
                ^
/home/meghan/src/zig/src/main.zig:269:31: 0x990354 in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .zig_test);
                              ^
/home/meghan/src/zig/src/main.zig:207:20: 0x98f805 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/meghan/src/zig/lib/std/start.zig:616:37: 0x991ee7 in main (zig)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7ffafc85b236 in ??? (???)
???:?:?: 0x7ffe3acf7e00 in ??? (???)
Aborted (core dumped)

Expected Behavior

all tests passed

@nektro nektro added the bug Observed behavior contradicts documented or intended behavior label Feb 12, 2023
@nektro nektro changed the title stage2/lllvm: panic in lowering maxInt(u32) global stage2/lllvm: panic in lowering maxInt(u32) slice end Feb 12, 2023
@Vexu
Copy link
Member

Vexu commented Feb 12, 2023

Duplicate of #1424

@Vexu Vexu marked this as a duplicate of #1424 Feb 12, 2023
@Vexu Vexu closed this as completed Feb 12, 2023
@nektro
Copy link
Contributor Author

nektro commented Feb 12, 2023

14627 is the one thats a duplicate, no?

@nektro
Copy link
Contributor Author

nektro commented Feb 12, 2023

also neither are trying to create an array

@Vexu
Copy link
Member

Vexu commented Feb 12, 2023

This could be fixed by switching to the C++ API while the other one requires some work from our side and both are creating arrays since slicing with comptime-known bounds creates an array.

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
Projects
None yet
Development

No branches or pull requests

2 participants