]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix abort handling on arm64
authorAustin Clements <austin@google.com>
Fri, 9 Mar 2018 21:12:40 +0000 (16:12 -0500)
committerAustin Clements <austin@google.com>
Fri, 9 Mar 2018 22:17:04 +0000 (22:17 +0000)
The implementation of runtime.abort on arm64 currently branches to
address 0, which results in a signal from PC 0, rather than from
runtime.abort, so the runtime fails to recognize it as an abort.

Fix runtime.abort on arm64 to read from address 0 like what other
architectures do and recognize this in the signal handler.

Should fix the linux/arm64 build.

Change-Id: I960ab630daaeadc9190287604d4d8337b1ea3853
Reviewed-on: https://go-review.googlesource.com/99895
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/asm_arm64.s
src/runtime/os3_plan9.go
src/runtime/panic.go
src/runtime/signal_sighandler.go
src/runtime/signal_windows.go

index e88532728a383ea06e1e6d2b2568dea8fc54d4bd..2b39d2ec727f6de50deadd2eee2c7e2c69e3b164 100644 (file)
@@ -710,7 +710,8 @@ TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-8
        RET
 
 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
-       B       (ZR)
+       MOVD    ZR, R0
+       MOVD    (R0), R0
        UNDEF
 
 TEXT runtime·return0(SB), NOSPLIT, $0
index 9158c44f2f0a8be26b8aabc3629599e7281c3a6d..0e3a4c8024e195aa29d8e3519bfb139517ce3f98 100644 (file)
@@ -35,7 +35,7 @@ func sighandler(_ureg *ureg, note *byte, gp *g) int {
                print("sighandler: note is longer than ERRMAX\n")
                goto Throw
        }
-       if c.pc() == funcPC(abort) || (GOARCH == "arm" && c.pc() == funcPC(abort)+4) {
+       if isAbortPC(c.pc()) {
                // Never turn abort into a panic.
                goto Throw
        }
index d9fa512530ba1350380aaebe7596b8fc69b9679f..10945ace0d651690f313626c68e1684b0f7920b4 100644 (file)
@@ -837,3 +837,9 @@ func shouldPushSigpanic(gp *g, pc, lr uintptr) bool {
        // will work.
        return true
 }
+
+// isAbortPC returns true if pc is the program counter at which
+// runtime.abort raises a signal.
+func isAbortPC(pc uintptr) bool {
+       return pc == funcPC(abort) || ((GOARCH == "arm" || GOARCH == "arm64") && pc == funcPC(abort)+sys.PCQuantum)
+}
index 3004e36769181e8bd02abcb19b44e163f0979d69..b75e98b262116a8fa7084b42b422a356aaf1dfb1 100644 (file)
@@ -43,7 +43,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
                // stack. Abort in the signal handler instead.
                flags = (flags &^ _SigPanic) | _SigThrow
        }
-       if c.sigpc() == funcPC(abort) || (GOARCH == "arm" && c.sigpc() == funcPC(abort)+4) {
+       if isAbortPC(c.sigpc()) {
                // On many architectures, the abort function just
                // causes a memory fault. Don't turn that into a panic.
                flags = _SigThrow
index 4d55f0fe6c51af3caf2062a271dc27ce13f9e93e..ad08019fc1bb0a031b1fa6850a0684bd91282bdf 100644 (file)
@@ -46,7 +46,7 @@ func isgoexception(info *exceptionrecord, r *context) bool {
                return false
        }
 
-       if r.ip() == funcPC(abort) || (GOARCH == "arm" && r.ip() == funcPC(abort)+4) {
+       if isAbortPC(r.ip()) {
                // Never turn abort into a panic.
                return false
        }