aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/signal_unix.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2019-11-16 17:08:11 -0500
committerCherry Zhang <cherryyz@google.com>2019-11-18 18:18:46 +0000
commit73d20f8186a091c8d7e81b621136770981cf8e44 (patch)
tree0ff2c82fbabb9d4c15659ade016f7f1dbbbf55e9 /src/runtime/signal_unix.go
parentf9dd99cae3b08e2fea303b88ff6ffae6261f65b5 (diff)
downloadgo-73d20f8186a091c8d7e81b621136770981cf8e44.tar.gz
go-73d20f8186a091c8d7e81b621136770981cf8e44.zip
runtime: always use Go signal stack in non-cgo program
When initializing an M, we set up its signal stack to the gsignal stack if an alternate signal stack is not already set. On Android, an alternate signal stack is always set, even cgo is not used. This breaks the logic of saving/fetching G on the signal stack during VDSO, which assumes the signal stack is allocated by Go if cgo is not used (if cgo is used, we use TLS for saving G). When cgo is not used, we can always use the Go signal stack, even if an alternate signal stack is already set. Since cgo is not used, no one other than the Go runtime will care. Fixes #35554. Change-Id: Ia9d84cd55cb35097f3df46f37996589c86f10e0f Reviewed-on: https://go-review.googlesource.com/c/go/+/207445 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/signal_unix.go')
-rw-r--r--src/runtime/signal_unix.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
index f42de36acc..756467f4df 100644
--- a/src/runtime/signal_unix.go
+++ b/src/runtime/signal_unix.go
@@ -1016,13 +1016,15 @@ func minitSignals() {
// stack to the gsignal stack. If the alternate signal stack is set
// for the thread (the case when a non-Go thread sets the alternate
// signal stack and then calls a Go function) then set the gsignal
-// stack to the alternate signal stack. Record which choice was made
-// in newSigstack, so that it can be undone in unminit.
+// stack to the alternate signal stack. We also set the alternate
+// signal stack to the gsignal stack if cgo is not used (regardless
+// of whether it is already set). Record which choice was made in
+// newSigstack, so that it can be undone in unminit.
func minitSignalStack() {
_g_ := getg()
var st stackt
sigaltstack(nil, &st)
- if st.ss_flags&_SS_DISABLE != 0 {
+ if st.ss_flags&_SS_DISABLE != 0 || !iscgo {
signalstack(&_g_.m.gsignal.stack)
_g_.m.newSigstack = true
} else {