Zig Version
0.17.0-dev.313+27be3b069
Steps to Reproduce and Observed Behavior
This issue is split out from #35307 (this comment and this comment), because it is a separate issue to the original problem. Latest example by @1off reproduced below.
Checkout https://github.com/zigtools/zls at commit f0bb3d2780, then try to build with zig build check -fincremental --watch.
ziglang.org tarball:
$ ~/Downloads/zig-x86_64-linux-0.17.0-dev.313+27be3b069/zig build check -fincremental --watch
check
└─ compile exe zls Debug native
└─ run exe zls_gen (version_data.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/1210fa2b6befa8aa5da96122c5c098fb/zls_gen --langref-version master --langref-path /home/rad/lab/zls/src/tools/langref.html.in --generate-version-data /home/rad/lab/zls/.zig-cache/o/68195cf24a3bbf340fba20d215786b02/version_data.zig
check
└─ compile exe zls Debug native
└─ run exe lsp-codegen (lsp_types.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/fd92e7de8b7a4d575e9d368603cfb389/lsp-codegen /home/rad/lab/zls/.zig-cache/o/04088ba3fd4930bdce1aea303f62da1b/lsp_types.zig
Build Summary: 5/9 steps succeeded (2 failed)
Debug build of Zig:
$ ~/lab/zig/build/stage5/bin/zig version
0.17.0-dev.313+27be3b069
$ ~/lab/zig/build/stage5/bin/zig build check -fincremental --watch
check
└─ compile exe zls Debug native
└─ run exe zls_gen (version_data.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen --langref-version master --langref-path /home/rad/lab/zls/src/tools/langref.html.in --generate-version-data /home/rad/lab/zls/.zig-cache/o/3086aff2e0e1b7b0019665717ba92792/version_data.zig
check
└─ compile exe zls Debug native
└─ run exe lsp-codegen (lsp_types.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen /home/rad/lab/zls/.zig-cache/o/4dbbfbbc2ebf7274fc938e687737597d/lsp_types.zig
Build Summary: 5/9 steps succeeded (2 failed)
Debugging the crashing binaries:
$ lldb ./.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen
(lldb) target create "./.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen"
Current executable set to '/home/rad/lab/zls/.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen' (x86_64).
(lldb) run
warning: failed to set breakpoint site at 0x918f50 for breakpoint -2.1: error: 9 sending the breakpoint request
warning: failed to set breakpoint site at 0x918f50 for breakpoint -2.1: error: 9 sending the breakpoint request
Process 167463 launched: '/home/rad/lab/zls/.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen' (x86_64)
Process 167463 stopped
* thread #1, name = 'zls_gen', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x918f50)
frame #0: 0x0000000000918f50 zls_gen`_start
zls_gen`_start:
-> 0x918f50 <+0>: xorl %ebp, %ebp
0x918f52 <+2>: movq %rsp, %rdi
0x918f55 <+5>: andq $-0x10, %rsp
0x918f59 <+9>: movq 0ドルx940620, %rax ; imm = 0x940620
$ lldb ./.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen
(lldb) target create "./.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen"
Current executable set to '/home/rad/lab/zls/.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen' (x86_64).
(lldb) run
warning: failed to set breakpoint site at 0x919050 for breakpoint -2.1: error: 9 sending the breakpoint request
warning: failed to set breakpoint site at 0x919050 for breakpoint -2.1: error: 9 sending the breakpoint request
Process 167498 launched: '/home/rad/lab/zls/.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen' (x86_64)
Process 167498 stopped
* thread #1, name = 'lsp-codegen', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x919050)
frame #0: 0x0000000000919050 lsp-codegen`_start
lsp-codegen`_start:
-> 0x919050 <+0>: xorl %ebp, %ebp
0x919052 <+2>: movq %rsp, %rdi
0x919055 <+5>: andq $-0x10, %rsp
0x919059 <+9>: movq 0ドルx91e620, %rax ; imm = 0x91E620
Expected Behavior
The zls_gen and lsp-codegen binaries should not segfault.
zls_gen binary
lsp-codegen binary
### Zig Version
0.17.0-dev.313+27be3b069
### Steps to Reproduce and Observed Behavior
This issue is split out from #35307 ([this comment](https://codeberg.org/ziglang/zig/issues/35307#issuecomment-15206691) and [this comment](https://codeberg.org/ziglang/zig/issues/35307#issuecomment-15400001)), because it is a separate issue to the original problem. Latest example by @1off reproduced below.
---
Checkout `https://github.com/zigtools/zls` at commit `f0bb3d2780`, then try to build with `zig build check -fincremental --watch`.
ziglang.org tarball:
```console
$ ~/Downloads/zig-x86_64-linux-0.17.0-dev.313+27be3b069/zig build check -fincremental --watch
check
└─ compile exe zls Debug native
└─ run exe zls_gen (version_data.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/1210fa2b6befa8aa5da96122c5c098fb/zls_gen --langref-version master --langref-path /home/rad/lab/zls/src/tools/langref.html.in --generate-version-data /home/rad/lab/zls/.zig-cache/o/68195cf24a3bbf340fba20d215786b02/version_data.zig
check
└─ compile exe zls Debug native
└─ run exe lsp-codegen (lsp_types.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/fd92e7de8b7a4d575e9d368603cfb389/lsp-codegen /home/rad/lab/zls/.zig-cache/o/04088ba3fd4930bdce1aea303f62da1b/lsp_types.zig
Build Summary: 5/9 steps succeeded (2 failed)
```
Debug build of Zig:
```console
$ ~/lab/zig/build/stage5/bin/zig version
0.17.0-dev.313+27be3b069
$ ~/lab/zig/build/stage5/bin/zig build check -fincremental --watch
check
└─ compile exe zls Debug native
└─ run exe zls_gen (version_data.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen --langref-version master --langref-path /home/rad/lab/zls/src/tools/langref.html.in --generate-version-data /home/rad/lab/zls/.zig-cache/o/3086aff2e0e1b7b0019665717ba92792/version_data.zig
check
└─ compile exe zls Debug native
└─ run exe lsp-codegen (lsp_types.zig) failure
error: process terminated with signal SEGV
failed command: ./.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen /home/rad/lab/zls/.zig-cache/o/4dbbfbbc2ebf7274fc938e687737597d/lsp_types.zig
Build Summary: 5/9 steps succeeded (2 failed)
```
Debugging the crashing binaries:
```console
$ lldb ./.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen
(lldb) target create "./.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen"
Current executable set to '/home/rad/lab/zls/.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen' (x86_64).
(lldb) run
warning: failed to set breakpoint site at 0x918f50 for breakpoint -2.1: error: 9 sending the breakpoint request
warning: failed to set breakpoint site at 0x918f50 for breakpoint -2.1: error: 9 sending the breakpoint request
Process 167463 launched: '/home/rad/lab/zls/.zig-cache/o/3e11733faaeb9b7c0b4eb90fa7d53a1b/zls_gen' (x86_64)
Process 167463 stopped
* thread #1, name = 'zls_gen', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x918f50)
frame #0: 0x0000000000918f50 zls_gen`_start
zls_gen`_start:
-> 0x918f50 <+0>: xorl %ebp, %ebp
0x918f52 <+2>: movq %rsp, %rdi
0x918f55 <+5>: andq $-0x10, %rsp
0x918f59 <+9>: movq 0ドルx940620, %rax ; imm = 0x940620
$ lldb ./.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen
(lldb) target create "./.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen"
Current executable set to '/home/rad/lab/zls/.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen' (x86_64).
(lldb) run
warning: failed to set breakpoint site at 0x919050 for breakpoint -2.1: error: 9 sending the breakpoint request
warning: failed to set breakpoint site at 0x919050 for breakpoint -2.1: error: 9 sending the breakpoint request
Process 167498 launched: '/home/rad/lab/zls/.zig-cache/o/ecb09c1acd0b1c324bd267980a2bb2e9/lsp-codegen' (x86_64)
Process 167498 stopped
* thread #1, name = 'lsp-codegen', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x919050)
frame #0: 0x0000000000919050 lsp-codegen`_start
lsp-codegen`_start:
-> 0x919050 <+0>: xorl %ebp, %ebp
0x919052 <+2>: movq %rsp, %rdi
0x919055 <+5>: andq $-0x10, %rsp
0x919059 <+9>: movq 0ドルx91e620, %rax ; imm = 0x91E620
```
### Expected Behavior
The `zls_gen` and `lsp-codegen` binaries should not segfault.
[zls_gen binary](https://codeberg.org/attachments/16073e5c-c696-4661-91ce-71dc5e36210f)
[lsp-codegen binary](https://codeberg.org/attachments/918f5591-d5d1-4f5e-901e-d2a68306d72e)