Skip to content

Commit

Permalink
runtime: correct caller PC/SP offsets in walltime1/nanotime1
Browse files Browse the repository at this point in the history
In walltime1/nanotime1, we save the caller's PC and SP for stack
unwinding. The code does that assumed zero frame size. Now that
the frame size is not zero, correct the offset. Rewrite it in a
way that doesn't depend on hard-coded frame size.

May fix #37127.

Change-Id: I47d6d54fc3499d7d5946c3f6a2dbd24fbd679de1
Reviewed-on: https://go-review.googlesource.com/c/go/+/219118
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
  • Loading branch information
cherrymui committed Feb 13, 2020
1 parent 123f7dd commit 3eab754
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/runtime/sys_linux_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ TEXT runtime·walltime1(SB), NOSPLIT, $0-12
MOVL g_m(AX), SI // SI unchanged by C code.

// Set vdsoPC and vdsoSP for SIGPROF traceback.
MOVL 0(SP), DX
MOVL DX, m_vdsoPC(SI)
LEAL sec+0(SP), DX
LEAL sec+0(FP), DX
MOVL -4(DX), CX
MOVL CX, m_vdsoPC(SI)
MOVL DX, m_vdsoSP(SI)

CMPL AX, m_curg(SI) // Only switch if on curg.
Expand Down Expand Up @@ -296,9 +296,9 @@ TEXT runtime·nanotime1(SB), NOSPLIT, $0-8
MOVL g_m(AX), SI // SI unchanged by C code.

// Set vdsoPC and vdsoSP for SIGPROF traceback.
MOVL 0(SP), DX
MOVL DX, m_vdsoPC(SI)
LEAL ret+0(SP), DX
LEAL ret+0(FP), DX
MOVL -4(DX), CX
MOVL CX, m_vdsoPC(SI)
MOVL DX, m_vdsoSP(SI)

CMPL AX, m_curg(SI) // Only switch if on curg.
Expand Down
12 changes: 6 additions & 6 deletions src/runtime/sys_linux_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ TEXT runtime·walltime1(SB),NOSPLIT,$8-12
MOVQ g_m(AX), BX // BX unchanged by C code.

// Set vdsoPC and vdsoSP for SIGPROF traceback.
MOVQ 0(SP), DX
MOVQ DX, m_vdsoPC(BX)
LEAQ sec+0(SP), DX
LEAQ sec+0(FP), DX
MOVQ -8(DX), CX
MOVQ CX, m_vdsoPC(BX)
MOVQ DX, m_vdsoSP(BX)

CMPQ AX, m_curg(BX) // Only switch if on curg.
Expand Down Expand Up @@ -275,9 +275,9 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$8-8
MOVQ g_m(AX), BX // BX unchanged by C code.

// Set vdsoPC and vdsoSP for SIGPROF traceback.
MOVQ 0(SP), DX
MOVQ DX, m_vdsoPC(BX)
LEAQ ret+0(SP), DX
LEAQ ret+0(FP), DX
MOVQ -8(DX), CX
MOVQ CX, m_vdsoPC(BX)
MOVQ DX, m_vdsoSP(BX)

CMPQ AX, m_curg(BX) // Only switch if on curg.
Expand Down

0 comments on commit 3eab754

Please sign in to comment.