From: Austin Clements Date: Thu, 26 May 2016 00:56:56 +0000 (-0400) Subject: runtime: unwind BP in jmpdefer to match SP unwind X-Git-Tag: go1.7beta1~81 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b92f4238790c590168e7dae03165d75deb89fe41;p=gostls13.git runtime: unwind BP in jmpdefer to match SP unwind The irregular calling convention for defers currently incorrectly manages the BP if frame pointers are enabled. Specifically, jmpdefer manipulates the SP as if its own caller, deferreturn, had returned. However, it does not manipulate the BP to match. As a result, when a BP-based traceback happens during a deferred function call, it unwinds to the function that performed the defer and then thinks that function called itself in an infinite regress. Fix this by making jmpdefer manipulate the BP as if deferreturn had actually returned. Fixes #12968. Updates #15840. Change-Id: Ic9cc7c863baeaf977883ed0c25a7e80e592cf066 Reviewed-on: https://go-review.googlesource.com/23457 Reviewed-by: Russ Cox Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index d6e5494180..e50c443044 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -526,6 +526,7 @@ TEXT runtime·jmpdefer(SB), NOSPLIT, $0-16 MOVQ fv+0(FP), DX // fn MOVQ argp+8(FP), BX // caller sp LEAQ -8(BX), SP // caller sp after CALL + MOVQ -8(SP), BP // restore BP as if deferreturn returned (harmless if framepointers not in use) SUBQ $5, (SP) // return to CALL again MOVQ 0(DX), BX JMP BX // but first run the deferred function