From: Austin Clements Date: Wed, 18 Nov 2015 21:48:22 +0000 (-0500) Subject: runtime: fix sanity check in stackBarrier X-Git-Tag: go1.6beta1~223 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bb6fb929d6e5c2e401f4e3ebe2b7505845970e4b;p=gostls13.git runtime: fix sanity check in stackBarrier stackBarrier on amd64 sanity checks that it's unwinding the correct entry in the stack barrier array. However, this check is wrong in two ways that make it unlikely to catch anything, right or wrong: 1) It checks that savedLRPtr == SP, but, in fact, it should be that savedLRPtr+8 == SP because the RET that returned to stackBarrier popped the saved LR. However, we didn't notice this check was wrong because, 2) the sense of the conditional branch is also wrong. Fix both of these. Change-Id: I38ba1f652b0168b5b2c11b81637656241262af7c Reviewed-on: https://go-review.googlesource.com/17039 Reviewed-by: Russ Cox --- diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 705238cb6d..6ebe0dc8e6 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -378,8 +378,9 @@ TEXT runtime·stackBarrier(SB),NOSPLIT,$0 MOVQ stkbar_savedLRPtr(DX)(BX*1), R8 MOVQ stkbar_savedLRVal(DX)(BX*1), BX // Assert that we're popping the right saved LR. + ADDQ $8, R8 CMPQ R8, SP - JNE 2(PC) + JEQ 2(PC) MOVL $0, 0 // Record that this stack barrier was hit. ADDQ $1, g_stkbarPos(CX)