ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
35.25k stars 2.57k forks source link

Segmentation fault at address 0xaaaaaaaaaaaaaaaa on aarch64 mac w/ stage3 binary #12753

Closed zenspider closed 1 year ago

zenspider commented 2 years ago

Zig Version

0.10.0-dev.3636+507aae4a1

Steps to Reproduce

Build from source as per the wiki. I'm currently using an M2 (aarch64) mac with llvm via homebrew.

I've bisected across master from a known working SHA and identified 507aae4a1 as causing the segfault. My bisect script is below. The code in question for zig test (my confirmation) is previously working code w/o too much complexity. It seems to be any code tho afaict.

cmake .. \
      -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) \
      -DZIG_STATIC_LLVM=on \
      --install-prefix /usr/local

make install -j 12

cd ~/Work/git/searbsg/crafting_interpreters/zenspider/

zig version
zig test zlox.zig || exit 1 # FFS git

Possibly related to #12746 ?

Expected Behavior

code to run w/o segfault

Actual Behavior

Segmentation fault at address 0xaaaaaaaaaaaaaaaa
/Users/ryan/Work/git/ziglang/zig/src/value.zig:357:38: 0x10439bdb0 in value.Value.tag (zig1)
            return self.ptr_otherwise.tag;
                                     ^
/Users/ryan/Work/git/ziglang/zig/src/value.zig:904:32: 0x10461df7f in value.Value.toType (zig1)
        return switch (self.tag()) {
                               ^
/Users/ryan/Work/git/ziglang/zig/src/codegen/llvm.zig:2195:56: 0x10439d7df in codegen.llvm.Object.getStackTraceType (zig1)
        return mod.declPtr(stack_trace_decl).val.toType(undefined);
                                                       ^
...
zenspider commented 2 years ago

For those that stumble across this 73bbd1069 is the last working SHA

zenspider commented 2 years ago

Per suggestion in discord (via clara), I added -fno-stage1 to my zig test command and now no version of SHA works... They all segfault in the same way.

I can't find any version that works w/ that flag, so I'm not sure it's a valid verification.

andrewrk commented 2 years ago

Thanks for the bug report. In order to reproduce this, do I need the file zlox.zig?

kubkon commented 1 year ago

Could you provide the source code of your program so that we could repro it locally? Also, could you double check this still happens on latest master?

zenspider commented 1 year ago

No, I can't provide the source... But! All sorts of other errors with my zig bug files but no longer the screaming address in zig 0.11. Closing.