]> Cypherpunks repositories - gostls13.git/commit
runtime: make nanotime1 reentrant
authorCherry Zhang <cherryyz@google.com>
Wed, 5 Aug 2020 00:25:10 +0000 (20:25 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 10 Aug 2020 18:06:04 +0000 (18:06 +0000)
commita93a4c178025b52be85c9eb4b9f2815716a62d11
tree85499b8d785eea7bd3ec0752da80d285fd9d52f3
parentba9e10889976025ee1d027db6b1cad383ec56de8
runtime: make nanotime1 reentrant

Currently, nanotime1 (and walltime1) is not reentrant, in that it
sets m.vdsoSP at entry and clears it at exit. If a signal lands
in between, and nanotime1 is called from the signal handler, it
will clear m.vdsoSP while we are still in nanotime1. If (in the
unlikely event) it is signaled again, m.vdsoSP will be wrong,
which may cause the stack unwinding code to crash.

This CL makes it reentrant, by saving/restoring the previous
vdsoPC and vdsoSP, instead of setting it to 0 at exit.

TODO: have some way to test?

Change-Id: I9ee53b251f1d8a5a489c71d4b4c0df1dee70c3e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/246763
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/sys_linux_386.s
src/runtime/sys_linux_amd64.s
src/runtime/sys_linux_arm.s
src/runtime/sys_linux_arm64.s
src/runtime/sys_linux_mips64x.s
src/runtime/sys_linux_ppc64x.s