aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/signal_amd64.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-02-04 11:41:34 -0500
committerCherry Zhang <cherryyz@google.com>2021-02-08 17:48:48 +0000
commit22f9e1ccbc9db9a1d9ecbadca972264e5ad2f169 (patch)
tree0ca9252b1e3287d4f6ff77ef6c429df0dae5bb77 /src/runtime/signal_amd64.go
parent5d7dc53888c3c91ef4122d584a064bc24b6f7540 (diff)
downloadgo-22f9e1ccbc9db9a1d9ecbadca972264e5ad2f169.tar.gz
go-22f9e1ccbc9db9a1d9ecbadca972264e5ad2f169.zip
[dev.regabi] runtime: initialize special registers before sigpanic
In case that we are panicking in ABI0 context or external code, special registers are not initialized. Initialized them in injected code before calling sigpanic. TODO: Windows, Plan 9. Change-Id: I0919b80e7cc55463f3dd94f1f63cba305717270a Reviewed-on: https://go-review.googlesource.com/c/go/+/289710 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/signal_amd64.go')
-rw-r--r--src/runtime/signal_amd64.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/runtime/signal_amd64.go b/src/runtime/signal_amd64.go
index 6ab1f758c2..3eeb5e044f 100644
--- a/src/runtime/signal_amd64.go
+++ b/src/runtime/signal_amd64.go
@@ -65,11 +65,14 @@ func (c *sigctxt) preparePanic(sig uint32, gp *g) {
pc := uintptr(c.rip())
sp := uintptr(c.rsp())
+ // In case we are panicking from external code, we need to initialize
+ // Go special registers. We inject sigpanic0 (instead of sigpanic),
+ // which takes care of that.
if shouldPushSigpanic(gp, pc, *(*uintptr)(unsafe.Pointer(sp))) {
- c.pushCall(funcPC(sigpanic), pc)
+ c.pushCall(funcPC(sigpanic0), pc)
} else {
// Not safe to push the call. Just clobber the frame.
- c.set_rip(uint64(funcPC(sigpanic)))
+ c.set_rip(uint64(funcPC(sigpanic0)))
}
}