]> Cypherpunks repositories - gostls13.git/commit
runtime: don't inspect the stack for delayed signals from TSAN
authorCherry Mui <cherryyz@google.com>
Wed, 25 May 2022 14:15:28 +0000 (10:15 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 26 May 2022 22:21:35 +0000 (22:21 +0000)
commitd29d0314c1ee64b2cf925b9c8ee535a6e52c5386
treefaebe1a853a3c8f5c29c9f0f0b8345023e6a9967
parentdbf52204751b5231b28a977c9cda3189c9493b2e
runtime: don't inspect the stack for delayed signals from TSAN

Cgo TSAN (not the Go race detector) intercepts signals and calls
the signal handler at a later time. When the signal handler is
called, the memory may have changed, but the signal context
remains old. As the signal context and the memory don't match, it
is unsafe to unwind the stack from the signal PC and SP. We have
to ignore the signal.

It is probably also not safe to do async preemption, which relies
on the signal PC, and inspects and even writes to the stack (for
call injection).

We also inspect the stack for fatal signals (e.g. SIGSEGV), but I
think they are not delayed. For other signals we don't inspect
the stack, so they are probably fine.

Fixes #27540.

Change-Id: I5c80a7512265b8ea4a91422954dbff32c6c3a0d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/408218
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/signal_unix.go