From fd3976b5bb95a1c20d3069c631813130a561d74a Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 22 Mar 2025 09:30:49 +0100 Subject: [PATCH] windows: fix wrong register for first parameter I'm surprised this worked as long as it did, since it looks like the goroutine stack did not get scanned. Or maybe the RCX register contained the stack pointer by accident. In any case, it now uses the correct register (RCX instead of RDI on Windows) for passing the stack pointer as the first parameter. --- src/runtime/asm_amd64_windows.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/asm_amd64_windows.S b/src/runtime/asm_amd64_windows.S index 190523979..f1cebf863 100644 --- a/src/runtime/asm_amd64_windows.S +++ b/src/runtime/asm_amd64_windows.S @@ -12,8 +12,8 @@ tinygo_scanCurrentStack: pushq %r15 // Scan the stack. - subq $8, %rsp // adjust the stack before the call to maintain 16-byte alignment - movq %rsp, %rdi + subq $8, %rsp // adjust the stack before the call to maintain 16-byte alignment + movq %rsp, %rcx // pass the stack pointer as the first parameter callq tinygo_scanstack // Restore the stack pointer. Registers do not need to be restored as they