diff options
| author | Keith Randall <khr@golang.org> | 2020-08-20 14:22:30 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2020-09-18 17:21:06 +0000 |
| commit | d91d0762c7757c12c7d5f9e2ae3f170d5bd7ba84 (patch) | |
| tree | 9e8f3dfd38e462c88f765c4352ac1dbfa3d3ab55 /src/runtime/error.go | |
| parent | 65dfe4a772a4bc612219d93886e5c07290785ee6 (diff) | |
| download | go-d91d0762c7757c12c7d5f9e2ae3f170d5bd7ba84.tar.xz | |
runtime/debug: provide Addr method for errors from SetPanicOnFault
When we're building a panic that's triggered by a memory fault when
SetPanicOnFault has been called, include an Addr method. This
method reports the address at which the fault occurred.
Fixes #37023
RELNOTE=yes
Change-Id: Idff144587d6b75070fdc861a36efec76f4ec7384
Reviewed-on: https://go-review.googlesource.com/c/go/+/249677
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/error.go')
| -rw-r--r-- | src/runtime/error.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/runtime/error.go b/src/runtime/error.go index 386569bead..9e6cdf35dd 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -77,6 +77,26 @@ func (e errorString) Error() string { return "runtime error: " + string(e) } +type errorAddressString struct { + msg string // error message + addr uintptr // memory address where the error occurred +} + +func (e errorAddressString) RuntimeError() {} + +func (e errorAddressString) Error() string { + return "runtime error: " + e.msg +} + +// Addr returns the memory address where a fault occurred. +// The address provided is best-effort. +// The veracity of the result may depend on the platform. +// Errors providing this method will only be returned as +// a result of using runtime/debug.SetPanicOnFault. +func (e errorAddressString) Addr() uintptr { + return e.addr +} + // plainError represents a runtime error described a string without // the prefix "runtime error: " after invoking errorString.Error(). // See Issue #14965. |
