authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-06-19 08:25:25+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-06-19 08:25:49+02:00
logae3ab88153db9e83b3eb981121727be7c6bc3346
treed00f7279c897788b6f99eb4a31fe1d924f45ed9a
parenteed6464426046a3c9697fa24be4ae2f6274133e3
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux.x32: fix read of stack slot containing ctid in clone()

It's a 32-bit pointer and passed on the stack; the upper 32 bits of the stack slot are garbage. This means that we ask the kernel to write to some random 64-bit location, which it will just silently fail to do (the process is in x32 mode; nothing can be mapped up there), and consequently, the thread's child_tid field will never be populated, causing a later join() to hang.

1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/os/linux/x32.zig+1-1
......@@ -130,7 +130,7 @@ pub fn clone() callconv(.naked) u32 {
130130 \\ mov %%rdx,%%rdi
131131 \\ mov %%r8,%%rdx
132132 \\ mov %%r9,%%r8
133 \\ mov 8(%%rsp),%%r10
133 \\ mov 8(%%rsp),%%r10d
134134 \\ mov %%r11,%%r9
135135 \\ and $-16,%%rsi
136136 \\ sub $8,%%rsi