Skip to content

Assertion failed at ir.cpp:22760 in ir_analyze_container_member_access_inner #7813

@spadix0

Description

@spadix0

While trying to factor some comptime arguments into a struct for cZPeg, I ran into this:

$ zig build test                               
All 25 tests passed.
Semantic Analysis [85/655] Assertion failed at /Users/runner/work/1/s/src/stage1/ir.cpp:22760 in ir_analyze_container_member_access_inner. This is a bug in the Zig compiler.The following command terminated unexpectedly:
/Users/spadix/zig-macos-x86_64-0.8.0-dev.1001+811833658/zig test /Users/spadix/proj/czpeg/src/czpeg/re.zig --cache-dir /Users/spadix/proj/czpeg/zig-cache --global-cache-dir /Users/spadix/.cache/zig --name test 
error: the following build command failed with exit code 1:
/Users/spadix/proj/czpeg/zig-cache/o/fcb79c9b92ca39c2295f175ae6ea2441/build /Users/spadix/zig-macos-x86_64-0.8.0-dev.1001+811833658/zig /Users/spadix/proj/czpeg /Users/spadix/proj/czpeg/zig-cache /Users/spadix/.cache/zig test

The code to reproduce is here: https://github.com/spadix0/cZPeg/tree/zig_assert_ir_analyze_container
that may not compile even without the assertion, but all tests pass before the branch, so something in that (small) diff probably triggered the problem(?)

stack trace
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff736a133a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff7375de60 libsystem_pthread.dylib`pthread_kill + 430
    frame #2: 0x00007fff73628808 libsystem_c.dylib`abort + 120
    frame #3: 0x0000000100003866 zig`std.os.abort + 6
    frame #4: 0x00000001000048fe zig`std.debug.panicExtra + 910
    frame #5: 0x00000001000010d9 zig`std.builtin.default_panic + 25
    frame #6: 0x000000010000a32a zig`stage2_panic + 26
    frame #7: 0x00000001003684fc zig`zig_panic(char const*, ...) + 172
    frame #8: 0x00000001003f9c9c zig`ir_analyze_container_member_access_inner(IrAnalyze*, ZigType*, Buf*, IrInst*, IrInstGen*, IrInst*, ZigType*) + 828
    frame #9: 0x00000001003b5be3 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 66451
    frame #10: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #11: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #12: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #13: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #14: 0x00000001003b1819 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 49097
    frame #15: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #16: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #17: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #18: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #19: 0x00000001003b1819 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 49097
    frame #20: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #21: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #22: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #23: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #24: 0x00000001003b1819 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 49097
    frame #25: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #26: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #27: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #28: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #29: 0x00000001003b1819 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 49097
    frame #30: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #31: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #32: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #33: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #34: 0x00000001003aed75 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 38181
    frame #35: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #36: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #37: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #38: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #39: 0x00000001003b1819 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 49097
    frame #40: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #41: 0x00000001003a3201 zig`ir_eval_const_value(CodeGen*, Scope*, AstNode*, ZigValue*, unsigned long*, unsigned long*, ZigFn*, Buf*, AstNode*, Buf*, IrExecutableGen*, AstNode*, UndefAllowed) + 593
    frame #42: 0x00000001004007b5 zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 5173
    frame #43: 0x00000001004005cc zig`ir_analyze_fn_call(IrAnalyze*, IrInst*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier, IrInstGen*, IrInst*, bool, IrInstGen**, unsigned long, IrInstGen*, ResultLoc*) + 4684
    frame #44: 0x00000001003ff341 zig`ir_analyze_fn_call_src(IrAnalyze*, IrInstSrcCall*, ZigFn*, ZigType*, IrInstGen*, IrInstGen*, IrInst*, CallModifier) + 401
    frame #45: 0x00000001003b1819 zig`ir_analyze_instruction_base(IrAnalyze*, IrInstSrc*) + 49097
    frame #46: 0x00000001003a4a5b zig`ir_analyze(CodeGen*, IrExecutableSrc*, IrExecutableGen*, ZigType*, AstNode*, ZigValue*) + 1227
    frame #47: 0x000000010037d905 zig`analyze_fn_body(CodeGen*, ZigFn*) + 1269
    frame #48: 0x000000010037ef07 zig`semantic_analyze(CodeGen*) + 231
    frame #49: 0x000000010033c62f zig`codegen_build_object(CodeGen*) + 1439
    frame #50: 0x000000010033515e zig`zig_stage1_build_object + 2222
    frame #51: 0x00000001000dc8b0 zig`Compilation.performAllTheWork + 82544
    frame #52: 0x00000001000c1410 zig`Compilation.update + 1776
    frame #53: 0x0000000100089f4c zig`main.updateModule + 28
    frame #54: 0x000000010002cb2f zig`main.buildOutputType + 90319
    frame #55: 0x0000000100004a87 zig`main + 391
    frame #56: 0x00007fff73559cc9 libdyld.dylib`start + 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions