diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-25 01:29:58 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-25 01:30:37 +0000 |
commit | ff614b13d90961f55b1058bd798c6d4e92d3939c (patch) | |
tree | f32c351b78558d79e5ec49a62fa0f695f6f5dcab | |
parent | dbbc5ec7e87f1976188c57ce4fb0d41e324df687 (diff) | |
download | go-ff614b13d90961f55b1058bd798c6d4e92d3939c.tar.gz go-ff614b13d90961f55b1058bd798c6d4e92d3939c.zip |
runtime: subtract one from ip when determining abort
On windows/arm, the abort is given from one byte off of the function
address, perhaps because Windows wants to simulate x86/amd64 modes, or
because it's jumping from thumb mode. This is not the case with
windows/arm64, though.
This prevents a failure in the builders with the TestAbort test:
crash_test.go:727: output contains BAD:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: BAD: recovered from abort
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x6a5721]
Change-Id: I8939c60611863cc0c325e179a772601acea9fd4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/296153
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
-rw-r--r-- | src/runtime/signal_windows.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runtime/signal_windows.go b/src/runtime/signal_windows.go index 6215d0ba2d..63158f0bc4 100644 --- a/src/runtime/signal_windows.go +++ b/src/runtime/signal_windows.go @@ -45,9 +45,10 @@ func initExceptionHandler() { //go:nosplit func isAbort(r *context) bool { pc := r.ip() - if GOARCH == "386" || GOARCH == "amd64" { + if GOARCH == "386" || GOARCH == "amd64" || GOARCH == "arm" { // In the case of an abort, the exception IP is one byte after - // the INT3 (this differs from UNIX OSes). + // the INT3 (this differs from UNIX OSes). Note that on ARM, + // this means that the exception IP is no longer aligned. pc-- } return isAbortPC(pc) |