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

Freshly compiled Zig crashes on macOS #5119

Closed
tritao opened this issue Apr 21, 2020 · 2 comments · Fixed by #5125
Closed

Freshly compiled Zig crashes on macOS #5119

tritao opened this issue Apr 21, 2020 · 2 comments · Fixed by #5125

Comments

@tritao
Copy link

tritao commented Apr 21, 2020

Zig is crashing with stack trace below when running ./zig after compilation.

Compile commands:

(applied workaround from #5092)

cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) -GNinja -
DZIG_WORKAROUND_4799=1 && ninja

Stack trace via LLDB:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff4fa73e3e libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff4fbb2150 libsystem_pthread.dylib`pthread_kill + 333
    frame #2: 0x00007fff4f9d0312 libsystem_c.dylib`abort + 127
    frame #3: 0x000000010015e759 zig`std.os.abort at os.zig:213:17
    frame #4: 0x000000010014cdf0 zig`std.debug.panicExtra(trace=0x0000000000000000, first_trace_addr=<unavailable>, args=<unavailable>) at debug.zig:302:13
    frame #5: 0x000000010014bc3b zig`std.builtin.default_panic(msg=<unavailable>, error_return_trace=0x0000000000000000) at builtin.zig:548:33
    frame #6: 0x000000010014bc69 zig`std.debug.assert(ok=false) at debug.zig:228:14
    frame #7: 0x000000010021027c zig`std.debug.ModuleDebugInfo.getSymbolAtAddress(self=0x0000000106f7d018, address=0) at debug.zig:1415:19
    frame #8: 0x000000010020f147 zig`std.debug.printSourceAtAddress(debug_info=0x0000000105172ee0, out_stream=0x0000000105172ed8, address=0, tty_config=escape_codes) at debug.zig:578:54
    frame #9: 0x00000001001d1d72 zig`std.debug.writeCurrentStackTrace(out_stream=0x0000000105172ed8, debug_info=0x0000000105172ee0, tty_config=escape_codes, start_addr=<unavailable>) at debug.zig:402:33
    frame #10: 0x000000010015ec25 zig`std.debug.dumpCurrentStackTrace(start_addr=(val = 4296738909, maybe = true)) at debug.zig:124:27
    frame #11: 0x000000010014cd54 zig`std.debug.panicExtra(trace=0x0000000000000000, first_trace_addr=(val = 4296738909, maybe = true), args=std.builtin.struct:548:79 @ 0x00007ffeefbfca88) at debug.zig:274:38
    frame #12: 0x000000010014bc3b zig`std.builtin.default_panic(msg=<unavailable>, error_return_trace=0x0000000000000000) at builtin.zig:548:33
    frame #13: 0x00000001001b085d zig`std.zig.system.NativeTargetInfo.detect(allocator=0x0000000104fe19c8, cross_target=std.zig.cross_target.CrossTarget @ 0x00007ffeefbfdfc0) at system.zig:275:46
    frame #14: 0x000000010017ccaf zig`crossTargetToTarget(cross_target=std.zig.cross_target.CrossTarget @ 0x00007ffeefbfdfc0, dynamic_linker_ptr=0x00007ffeefbfdd38) at stage2.zig:1208:58
    frame #15: 0x00000001001bdbe3 zig`Stage2Target.fromTarget(self=0x00007ffeefbfeed8, cross_target=std.zig.cross_target.CrossTarget @ 0x00007ffeefbfdfc0) at stage2.zig:947:47
    frame #16: 0x00000001001562f5 zig`stage2TargetParse(stage1_target=0x00007ffeefbfeed8, zig_triple_oz=0x0000000000000000, mcpu_oz=0x0000000000000000, dynamic_linker_oz=0x0000000000000000) at stage2.zig:742:33
    frame #17: 0x0000000100155ce1 zig`stage2_target_parse(target=0x00007ffeefbfeed8, zig_triple=0x0000000000000000, mcpu=0x0000000000000000, dynamic_linker=0x0000000000000000) at stage2.zig:671:22
    frame #18: 0x00000001001443dd zig`target_parse_triple(target=0x00007ffeefbfeed8, triple=0x0000000000000000, mcpu=0x0000000000000000, dynamic_linker=0x0000000000000000) at target.cpp:413:12
    frame #19: 0x00000001000080d5 zig`main0(argc=1, argv=0x00007ffeefbff748) at main.cpp:1336:16
    frame #20: 0x0000000100002d44 zig`main(argc=1, argv=0x00007ffeefbff748) at main.cpp:1851:19
    frame #21: 0x00007fff4f924115 libdyld.dylib`start + 1
    frame #22: 0x00007fff4f924115 libdyld.dylib`start + 1

Stack trace via Zig:

reached unreachable code
???:?:?: 0x102e6385c in _std.zig.system.NativeTargetInfo.detect (???)
???:?:?: 0x102e2fcae in _crossTargetToTarget (???)
???:?:?: 0x102e70be2 in _Stage2Target.fromTarget (???)
???:?:?: 0x102e092f4 in _stage2TargetParse (???)
???:?:?: 0x102e08ce0 in _stage2_target_parse (???)
???:?:?: 0x102df73dc in __Z19target_parse_tripleP9ZigTargetPKcS2_S2_ (???)
../src/main.cpp:1336:16: 0x102cbb0d4 in main0 (../src/main.cpp)
    if ((err = target_parse_triple(&target, target_string, mcpu, dynamic_linker))) {
               ^
../src/main.cpp:1851:19: 0x102cb5d43 in main (../src/main.cpp)
    auto result = main0(argc, argv);
                  ^
???:?:?: 0x7fff4f924114 in ??? (???)
???:?:?: 0x0 in ??? (???)
[1]    76658 abort      ./zig
@LemonBoy
Copy link
Contributor

sysctlbynameZ is failing, what osx version are you on?

@tritao
Copy link
Author

tritao commented Apr 21, 2020

sysctlbynameZ is failing, what osx version are you on?

macOS 10.13.2 (High Sierra)

What can I do to help debug this?

mikdusan added a commit to mikdusan/zig that referenced this issue Apr 21, 2020
Fallback to sysctl `kern.osversion` when `kern.osproductversion` is not
available (prior to 10.13.4) .

The mapping from `sw_vers -buildVersion` to `-productVersion` is
formulaic from 10.8 to 10.15 and older is handled with switch.

closes ziglang#5119
mikdusan added a commit to mikdusan/zig that referenced this issue Apr 21, 2020
Fallback to sysctl `kern.osversion` when `kern.osproductversion` is not
available (prior to 10.13.4) .

The mapping from `sw_vers -buildVersion` to `-productVersion` is
formulaic from 10.8 to 10.15 and older is handled with switch.

closes ziglang#5119
mikdusan added a commit to mikdusan/zig that referenced this issue Apr 21, 2020
Fallback to sysctl `kern.osversion` when `kern.osproductversion` is not
available (prior to 10.13.4) .

The mapping from `sw_vers -buildVersion` to `-productVersion` is
formulaic from 10.8 to 10.15 and older is handled with switch.

closes ziglang#5119
mikdusan added a commit to mikdusan/zig that referenced this issue Apr 22, 2020
Fallback to sysctl `kern.osversion` when `kern.osproductversion` is not
available (prior to 10.13.4) .

The mapping from `sw_vers -buildVersion` to `-productVersion` is
formulaic from 10.8 to 10.15 and older is handled with switch.

closes ziglang#5119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants