From a8ba163695f605c72156c90de97a06b3e40566ff Mon Sep 17 00:00:00 2001 From: qmuntal Date: Wed, 24 Apr 2024 09:36:22 +0200 Subject: runtime: fix mcall unwinding on Windows The Windows native stack unwinder incorrectly classifies the next instruction after the mcall callback call as being part of the function epilogue, producing a wrong call stack. Add a NOP after the callback call to work around this issue. Fixes #67007. Change-Id: I6017635da895b272b1852391db9a255ca69e335d Reviewed-on: https://go-review.googlesource.com/c/go/+/581335 TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek Reviewed-by: Cherry Mui Run-TryBot: Quim Muntal LUCI-TryBot-Result: Go LUCI --- src/runtime/asm_amd64.s | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 1071d270c1..cb21629a84 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -456,6 +456,10 @@ goodm: PUSHQ AX // open up space for fn's arg spill slot MOVQ 0(DX), R12 CALL R12 // fn(g) + // The Windows native stack unwinder incorrectly classifies the next instruction + // as part of the function epilogue, producing a wrong call stack. + // Add a NOP to work around this issue. See go.dev/issue/67007. + BYTE $0x90 POPQ AX JMP runtime·badmcall2(SB) RET -- cgit v1.2.3-54-g00ecf