Hi! I’m seeing a reproducible crash with a minimal Zig 0.16 program on a native Intel Mac running macOS 26.2.
A Zig-produced x86_64-macos executable works fine when unsigned, but starts segfaulting after codesign.
Environment
macOS 26.2 (25C56)
MacBookPro16,1
uname -m: x86_64
zig: 0.16.0
zig path: /usr/local/Cellar/zig/0.16.0_1/bin/zig
Minimal repro
const std = @import("std");
pub fn main() void {
const msg = "hello\n";
_ = std.c.write(1, msg.ptr, msg.len);
}
Commands
zig build-exe hello.zig -O ReleaseFast -target x86_64-macos -lc -femit-bin=hello
./hello
echo $?
codesign -f -s - hello
./hello
echo $?
Observed behavior
hello
0
hello
Segmentation fault: 11
139
So main does run and prints hello, but the signed binary segfaults during/after process teardown.
Crash report summary:
EXC_BAD_ACCESS / SIGSEGV
KERN_INVALID_ADDRESS at 0x0000000000000001
The crash report includes a frame in Zig startup/runtime code around std/start.zig main.
Expected behavior
The signed Zig binary should continue to run successfully, like it does before signing.
Variants tested
I tried the following, and all signed binaries still crashed:
-fllvm
-flibllvm
-fno-lld
-funwind-tables
-fno-unwind-tables
-target x86_64-macos.10.15
-target x86_64-macos.11.0
-target x86_64-macos.13.0
-target x86_64-macos.26.2
Control test
A C binary signed with the same local ad-hoc signing command works correctly on the same machine:
#include <stdio.h>
int main() { puts("hello-c"); return 0; }
cc hello.c -o hello-c
codesign -f -s - hello-c
./hello-c
echo $?
Output:
hello-c
0
Context
I found this while debugging justrach/codedb on native Intel macOS. Their codedb-darwin-x86_64 release asset is Developer ID signed and crashes with Segmentation fault: 11; the same source built locally and left unsigned runs.
A minimal Zig program reproduces the same signed-vs-unsigned behavior, so this does not appear to be specific to that project.
This may be related to Zig/Mach-O/x86_64/macOS Tahoe issues such as:
I tried to open an issue or comment upstream on GitHub, but interactions on ziglang/zig appear to be restricted to collaborators only, so I’m posting here first.
Does anyone know whether this is a known Zig 0.16 Mach-O signing issue on Intel macOS 26, or whether there’s a linker/build flag workaround for producing a signed x86_64-macos binary that runs correctly?