Skip to content

Compiler segfault in hash_const_val #3842

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
jayschwa opened this issue Dec 4, 2019 · 0 comments
Closed

Compiler segfault in hash_const_val #3842

jayschwa opened this issue Dec 4, 2019 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@jayschwa
Copy link
Contributor

jayschwa commented Dec 4, 2019

$ ~/zig/build/zig version
0.5.0+38791ac61
const std = @import("std");

const Point = struct {
    x: isize,
    y: isize,
};

pub fn main() !void {
    const allocator = std.debug.global_allocator;
    const stdin = &std.io.getStdIn().inStream().stream;
    const stdout = &std.io.getStdOut().outStream().stream;

    const wires = [_]*std.ArrayList(Point) {
        &std.ArrayList(Point).init(allocator),
        &std.ArrayList(Point).init(allocator),
    };

    stdout.print("{}\n", wires);
}
$ lldb -- ~/zig/build/zig build-exe ~/crashes.zig 
(lldb) target create "/home/jayschwa/zig/build/zig"
Current executable set to '/home/jayschwa/zig/build/zig' (x86_64).
(lldb) settings set -- target.run-args  "build-exe" "/home/jayschwa/crashes.zig"
(lldb) run
Process 23262 launched: '/home/jayschwa/zig/build/zig' (x86_64)
Process 23262 stopped
* thread #1, name = 'zig', stop reason = signal SIGSEGV: invalid address (fault address: 0x12)
    frame #0: 0x00005555560c34e0 zig`::hash_const_val(const_val=0x000000000000000a) at analyze.cpp:5084:5
   5081	}
   5082	
   5083	static uint32_t hash_const_val(ZigValue *const_val) {
-> 5084	    assert(const_val->special == ConstValSpecialStatic);
   5085	    switch (const_val->type->id) {
   5086	        case ZigTypeIdOpaque:
   5087	            zig_unreachable();
(lldb) bt
* thread #1, name = 'zig', stop reason = signal SIGSEGV: invalid address (fault address: 0x12)
  * frame #0: 0x00005555560c34e0 zig`::hash_const_val(const_val=0x000000000000000a) at analyze.cpp:5084:5
    frame #1: 0x00005555560c9a06 zig`type_id_hash(x=TypeId @ 0x00007fffffffd300) at analyze.cpp:7042:58
    frame #2: 0x00005555560d4e04 zig`HashMap<TypeId, ZigType*, &(type_id_hash(TypeId)), &(type_id_eql(TypeId, TypeId))>::key_to_index(this=0x000055555871d640, key=0x00007fffffffd420) const at hash_map.hpp:238:34
    frame #3: 0x00005555560d378b zig`HashMap<TypeId, ZigType*, &(type_id_hash(TypeId)), &(type_id_eql(TypeId, TypeId))>::internal_get(this=0x000055555871d640, key=0x00007fffffffd420) const at hash_map.hpp:223:13
    frame #4: 0x00005555560d2b5d zig`HashMap<TypeId, ZigType*, &(type_id_hash(TypeId)), &(type_id_eql(TypeId, TypeId))>::maybe_get(this=0x000055555871d640, key=0x00007fffffffd420) const at hash_map.hpp:81:32
    frame #5: 0x00005555560b4875 zig`get_pointer_to_type_extra2(g=0x000055555871d4c0, child_type=0x000055555f2afa20, is_const=true, is_volatile=false, ptr_len=PtrLenUnknown, byte_alignment=0, bit_offset_in_host=0, host_int_bytes=0, allow_zero=false, vector_index=4294967295, inferred_struct_field=0x0000000000000000, sentinel=0x000000000000000a) at analyze.cpp:554:54
    frame #6: 0x0000555556058d53 zig`::type_info_to_type(ira=0x000055555f527e30, instruction=0x000055555f53b8d0, tagTypeId=ZigTypeIdPointer, payload=0x000055555f539530) at ir.cpp:22939:63
    frame #7: 0x00005555560591a4 zig`::ir_analyze_instruction_type(ira=0x000055555f527e30, instruction=0x000055555f51e3f0) at ir.cpp:23015:38
    frame #8: 0x000055555606bbdf zig`::ir_analyze_instruction_base(ira=0x000055555f527e30, instruction=0x000055555f51e3f0) at ir.cpp:27953:47
    frame #9: 0x000055555606c3ac zig`ir_analyze(codegen=0x000055555871d4c0, old_exec=0x000055555f420760, new_exec=0x000055555f4205a0, expected_type=0x0000555559104140, expected_type_source_node=0x00005555591ea360) at ir.cpp:28100:69
    frame #10: 0x00005555560c1a14 zig`::analyze_fn_ir(g=0x000055555871d4c0, fn=0x000055555f420520, return_type_node=0x00005555591ea360) at analyze.cpp:4606:44
    frame #11: 0x00005555560c1fe5 zig`::analyze_fn_body(g=0x000055555871d4c0, fn_table_entry=0x000055555f420520) at analyze.cpp:4714:18
    frame #12: 0x00005555560c2886 zig`semantic_analyze(g=0x000055555871d4c0) at analyze.cpp:4826:28
    frame #13: 0x0000555555fee906 zig`::gen_root_source(g=0x000055555871d4c0) at codegen.cpp:9239:25
    frame #14: 0x0000555555ff2757 zig`codegen_build_and_link(g=0x000055555871d4c0) at codegen.cpp:10244:28
    frame #15: 0x0000555555fc55ad zig`main(argc=3, argv=0x00007fffffffdf88) at main.cpp:1286:39
    frame #16: 0x00007ffff38891e3 libc.so.6`__libc_start_main(main=(zig`main at main.cpp:328:33), argc=3, argv=0x00007fffffffdf88, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffdf78) at libc-start.c:308:16
    frame #17: 0x0000555555fbfb7e zig`_start + 46
LemonBoy added a commit to LemonBoy/zig that referenced this issue Dec 6, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Dec 6, 2019
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Dec 6, 2019
andrewrk added a commit that referenced this issue Dec 6, 2019
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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants