diff options
| author | Austin Clements <austin@google.com> | 2018-01-18 17:33:04 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-03-08 22:55:55 +0000 |
| commit | 60a9e5d613d6de21735e54ca62246e3f8ef8c8d3 (patch) | |
| tree | 624041ce95b576aea8c360107d5560c980a5f268 /src/runtime/testdata | |
| parent | c950a90d7240a6f2124ae38564c137b86866b191 (diff) | |
| download | go-60a9e5d613d6de21735e54ca62246e3f8ef8c8d3.tar.xz | |
runtime: ensure abort actually crashes the process
On all non-x86 arches, runtime.abort simply reads from nil.
Unfortunately, if this happens on a user stack, the signal handler
will dutifully turn this into a panicmem, which lets user defers run
and which user code can even recover from.
To fix this, add an explicit check to the signal handler that turns
faults in abort into hard crashes directly in the signal handler. This
has the added benefit of giving a register dump at the abort point.
Change-Id: If26a7f13790745ee3867db7f53b72d8281176d70
Reviewed-on: https://go-review.googlesource.com/93661
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/testdata')
| -rw-r--r-- | src/runtime/testdata/testprog/abort.go | 23 | ||||
| -rw-r--r-- | src/runtime/testdata/testprog/empty.s | 5 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/abort.go b/src/runtime/testdata/testprog/abort.go new file mode 100644 index 0000000000..9e79d4dea3 --- /dev/null +++ b/src/runtime/testdata/testprog/abort.go @@ -0,0 +1,23 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import _ "unsafe" // for go:linkname + +func init() { + register("Abort", Abort) +} + +//go:linkname runtimeAbort runtime.abort +func runtimeAbort() + +func Abort() { + defer func() { + recover() + panic("BAD: recovered from abort") + }() + runtimeAbort() + println("BAD: after abort") +} diff --git a/src/runtime/testdata/testprog/empty.s b/src/runtime/testdata/testprog/empty.s new file mode 100644 index 0000000000..c5aa6f8a54 --- /dev/null +++ b/src/runtime/testdata/testprog/empty.s @@ -0,0 +1,5 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This exists solely so we can linkname in symbols from runtime. |
