aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-12-17 15:35:49 -0800
committerAustin Clements <austin@google.com>2015-12-18 17:08:32 +0000
commita4a57bb4f9a7d4d2d7f4cbe373ab446d73c25966 (patch)
tree3bccdf0b4fbceff43d80840f8b30729a447b9d48 /src
parent90a68935733ef37d41cb520ffeb56f196a356811 (diff)
downloadgo-a4a57bb4f9a7d4d2d7f4cbe373ab446d73c25966.tar.xz
runtime: prevent race between setNextBarrierPC and sigprof
Currently, setNextBarrierPC manipulates the stack barriers without acquiring the stack barrier lock. This is mostly okay because setNextBarrierPC also runs synchronously on the G and prevents safe points, but this doesn't prevent a sigprof from occurring during a setNextBarrierPC and performing a traceback. Given that setNextBarrierPC simply sets one entry in the stack barrier array, this is almost certainly safe in reality. However, given that this depends on a subtle argument, which may not hold in the future, and that setNextBarrierPC almost never happens, making it nowhere near performance-critical, we can simply acquire the stack barrier lock and be sure that the synchronization will work. Updates #12528. For 1.5.3. Change-Id: Ife696e10d969f190157eb1cbe762a2de2ebce079 Reviewed-on: https://go-review.googlesource.com/18022 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mstkbar.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/mstkbar.go b/src/runtime/mstkbar.go
index 6b4fc8d4a6..7d7235d259 100644
--- a/src/runtime/mstkbar.go
+++ b/src/runtime/mstkbar.go
@@ -305,7 +305,9 @@ func nextBarrierPC() uintptr {
//go:nosplit
func setNextBarrierPC(pc uintptr) {
gp := getg()
+ gcLockStackBarriers(gp)
gp.stkbar[gp.stkbarPos].savedLRVal = pc
+ gcUnlockStackBarriers(gp)
}
// gcLockStackBarriers synchronizes with tracebacks of gp's stack