Skip to content

Failed Compiler Assertion during Function Call and Catch #3007

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

Closed
iguessthislldo opened this issue Aug 5, 2019 · 3 comments
Closed

Failed Compiler Assertion during Function Call and Catch #3007

iguessthislldo opened this issue Aug 5, 2019 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@iguessthislldo
Copy link

iguessthislldo commented Aug 5, 2019

Continued from #3006

With Prebuilt Zig 0.4.0+f01cb8cc on Linux:

const Foo = struct {
    free: bool,

    pub const FooError = error {
        NotFree,
    };
};

var foo = Foo{.free = true};
var default_foo: ?*Foo = null;

fn get_foo() Foo.FooError!*Foo {
    if (foo.free) {
        foo.free = false;
        return &foo;
    }
    return error.NotFree;
}

pub fn main() anyerror!void {
    default_foo = get_foo() catch null; // This Line
}

Produces the following failure:

when analyzing /mnt/arch/data/development/concepts/georgios/test/src/main.zig:21:5: assertion failed. This is a bug in the Zig compiler.
???:?:?: 0x7f0a55168f79 in ??? (???)


???:?:?: 0x7f0a551369ab in ??? (???)


The following command terminated unexpectedly:
/mnt/arch/data/programs/standalone/zig/zig build-exe /mnt/arch/data/development/concepts/georgios/test/src/main.zig --cache-dir /mnt/arch/data/development/concepts/georgios/test/zig-cache --name test --cache on 

Build failed. The following command failed:
/mnt/arch/data/development/concepts/georgios/test/zig-cache/o/6aH-HFCwb2haPT79Mxk1Fi3KvcPwp979F36Gw_Rek0vLcW30syWRAkD4rEMDQOB5/build /mnt/arch/data/programs/standalone/zig/zig /mnt/arch/data/development/concepts/georgios/test /mnt/arch/data/development/concepts/georgios/test/zig-cache
@SamTebbs33
Copy link
Contributor

Reproduced

when analyzing /home/samteb01/repos/zig/reproduce/foo.zig:21:5: assertion failed. This is a bug in the Zig compiler.
/home/samteb01/repos/zig/src-self-hosted/stage1.zig:37:5: 0xfc0759 in stage2_panic (userland)
    @panic(ptr[0..len]);
    ^
/home/samteb01/repos/zig/src/analyze.cpp:7289:0: 0xfa402c in src_assert (/home/samteb01/repos/zig/src/analyze.cpp)
    stage2_panic(msg, strlen(msg));

/home/samteb01/repos/zig/src/codegen.cpp:1903:0: 0xecb8e8 in ir_llvm_value (/home/samteb01/repos/zig/src/codegen.cpp)
        src_assert(instruction->value.special != ConstValSpecialRuntime, instruction->source_node);

/home/samteb01/repos/zig/src/codegen.cpp:3447:0: 0xed1cda in ir_render_store_ptr (/home/samteb01/repos/zig/src/codegen.cpp)
        LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);

/home/samteb01/repos/zig/src/codegen.cpp:5543:0: 0xeda726 in ir_render_instruction (/home/samteb01/repos/zig/src/codegen.cpp)
            return ir_render_store_ptr(g, executable, (IrInstructionStorePtr *)instruction);

/home/samteb01/repos/zig/src/codegen.cpp:5719:0: 0xedb0fa in ir_render (/home/samteb01/repos/zig/src/codegen.cpp)
            instruction->llvm_value = ir_render_instruction(g, executable, instruction);

/home/samteb01/repos/zig/src/codegen.cpp:6896:0: 0xee00ed in do_code_gen (/home/samteb01/repos/zig/src/codegen.cpp)
        ir_render(g, fn_table_entry);

/home/samteb01/repos/zig/src/codegen.cpp:9586:0: 0xee96e2 in codegen_build_and_link (/home/samteb01/repos/zig/src/codegen.cpp)
            do_code_gen(g);

/home/samteb01/repos/zig/src/main.cpp:1207:0: 0xebd9b9 in main (/home/samteb01/repos/zig/src/main.cpp)
                codegen_build_and_link(g);

???:?:?: 0x7ffff671482f in ??? (???)


???:?:?: 0xfde258d4c544154 in ??? (???)



Program received signal SIGSEGV, Segmentation fault.
0x0000000000ffe980 in std.debug.StackIterator.next (self=0x7fffffffd670) at /home/samteb01/repos/zig/std/debug.zig:298
298	        const return_address = @intToPtr(*const usize, self.fp + @sizeOf(usize)).*;

@SamTebbs33
Copy link
Contributor

Same assertion as #2791, so is a possible duplicate.

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Aug 11, 2019
@andrewrk andrewrk added this to the 0.5.0 milestone Aug 11, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 26, 2019
@Vexu
Copy link
Member

Vexu commented Nov 18, 2019

This works in master.

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

4 participants