]> Cypherpunks repositories - gostls13.git/commit
runtime: set g to gsignal before adjustSignalStack
authorCherry Zhang <cherryyz@google.com>
Mon, 15 Jun 2020 20:20:53 +0000 (16:20 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 15 Jun 2020 23:29:23 +0000 (23:29 +0000)
commitd286e61b6787fe2b55bf0ec8a814962ebda8d202
treeebc1d958166f258430cf9e0a5dfa80a1618fc664
parent41bdb9357a5f7ea6ade9a68aba56ee31b0f8dbbc
runtime: set g to gsignal before adjustSignalStack

When a signal is received, the runtime probes whether an
alternate signal stack is set, if so, adjust gsignal's stack to
point to the alternate signal stack. This is done in
adjustSignalStack, which calls sigaltstack "syscall", which is a
libc call on darwin through asmcgocall. asmcgocall decides
whether to do stack switch based on whether we're running on g0
stack, gsignal stack, or regular g stack. If g is not set to
gsignal, asmcgocall may make wrong decision. Set g first.
adjustSignalStack is recursively nosplit, so it is okay that
temporarily gsignal.stack doesn't match the stack we're running
on.

May fix #39079.

Change-Id: I59b2c5dc08c3c951f1098fff038bf2e06d7ca055
Reviewed-on: https://go-review.googlesource.com/c/go/+/238020
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/signal_unix.go