diff options
| author | Dan Scales <danscales@google.com> | 2019-12-10 17:27:26 -0800 |
|---|---|---|
| committer | Dan Scales <danscales@google.com> | 2019-12-12 19:23:45 +0000 |
| commit | 22d28a24c8b0d99f2ad6da5fe680fa3cfa216651 (patch) | |
| tree | df2e0b19717a826ae2d30bc981b5e7674870e368 /src/runtime/panic.go | |
| parent | 100bf440b9a69c6dce8daeebed038d607c963b8f (diff) | |
| download | go-22d28a24c8b0d99f2ad6da5fe680fa3cfa216651.tar.xz | |
runtime: force segv for nil defer function to be in deferreturn()
If the defer function pointer is nil, force the seg fault to happen in deferreturn
rather than in jmpdefer. jmpdefer is used fairly infrequently now because most
functions have open-coded defers.
The open-coded defer implementation calls gentraceback() with a callback when
looking for the first open-coded defer frame. gentraceback() throws an error if it
is called with a callback on an LR architecture and jmpdefer is on the stack,
because the stack trace can be incorrect in that case - see issue #8153. So, we
want to make sure that we don't have a seg fault in jmpdefer.
Fixes #36050
Change-Id: Ie25e6f015d8eb170b40248dedeb26a37b7f9b38d
Reviewed-on: https://go-review.googlesource.com/c/go/+/210978
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/panic.go')
| -rw-r--r-- | src/runtime/panic.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 0823f11e98..4cb6c8a360 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -561,6 +561,12 @@ func deferreturn(arg0 uintptr) { d.fn = nil gp._defer = d.link freedefer(d) + // If the defer function pointer is nil, force the seg fault to happen + // here rather than in jmpdefer. gentraceback() throws an error if it is + // called with a callback on an LR architecture and jmpdefer is on the + // stack, because the stack trace can be incorrect in that case - see + // issue #8153). + _ = fn.fn jmpdefer(fn, uintptr(unsafe.Pointer(&arg0))) } |
