Commit 59e33b447b

biexelar <biexelar@disroot.org>
2022-08-31 04:31:47
std.Thread: fix freeAndExit on x86_64-linux (#12693)
Previously, this function used incorrect registers for the munmap syscall, leading to detached threads not cleaning up. closes #12690 Co-authored-by: bxlr <biexelar@diroot.org>
1 parent 56cfa8f
Changed files (1)
lib
lib/std/Thread.zig
@@ -769,16 +769,13 @@ const LinuxThreadImpl = struct {
                 ),
                 .x86_64 => asm volatile (
                     \\  movq $11, %%rax
-                    \\  movq %[ptr], %%rbx
-                    \\  movq %[len], %%rcx
                     \\  syscall
                     \\  movq $60, %%rax
                     \\  movq $1, %%rdi
                     \\  syscall
                     :
-                    : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
-                      [len] "r" (self.mapped.len),
-                    : "memory"
+                    : [ptr] "{rdi}" (@ptrToInt(self.mapped.ptr)),
+                      [len] "{rsi}" (self.mapped.len),
                 ),
                 .arm, .armeb, .thumb, .thumbeb => asm volatile (
                     \\  mov r7, #91