]> Cypherpunks repositories - gostls13.git/commit
runtime: don't fetch G from signal stack when using cgo
authorCherry Zhang <cherryyz@google.com>
Thu, 31 Oct 2019 14:32:31 +0000 (10:32 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 5 Nov 2019 18:58:41 +0000 (18:58 +0000)
commitf07cbc7f88e5e15e41ec8b9c2b850d2179e0834e
treee49406289dc2b3e6f9f8cf3733d3f287f2f462da
parentfb05264fe1626c9d0b6d00d51e6c4d8d213d6dc7
runtime: don't fetch G from signal stack when using cgo

When using cgo, we save G to TLS, and when a signal happens, we
load G from TLS in sigtramp. This should give us a valid G. Don't
try to fetch from the signal stack. In particular, C code may
change the signal stack or call our signal handler directly (e.g.
TSAN), so we are not necessarily running on the original gsignal
stack where we saved G.

Also skip saving G on the signal stack when using cgo.

Updates #35249.

Change-Id: I40749ce6682709bd4ebfdfd9f23bd0f317fc197d
Reviewed-on: https://go-review.googlesource.com/c/go/+/204519
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/signal_unix.go
src/runtime/sys_linux_arm.s
src/runtime/sys_linux_arm64.s