diff options
| author | Austin Clements <austin@google.com> | 2018-03-08 17:48:22 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-03-08 23:35:46 +0000 |
| commit | 5d22cebb1272b3761860c5fa9ee82ceb3d94c628 (patch) | |
| tree | 208665ac819367aaaf61c8b4d658e93727ad385c /src/runtime/runtime2.go | |
| parent | 60a9e5d613d6de21735e54ca62246e3f8ef8c8d3 (diff) | |
| download | go-5d22cebb1272b3761860c5fa9ee82ceb3d94c628.tar.xz | |
runtime: explain and enforce that _panic values live on the stack
It's a bit mysterious that _defer.sp is a uintptr that gets
stack-adjusted explicitly while _panic.argp is an unsafe.Pointer that
doesn't, but turns out to be critically important when a deferred
function grows the stack before doing a recover.
Add a comment explaining that this works because _panic values live on
the stack. Enforce this by marking _panic go:notinheap.
Change-Id: I9ca49e84ee1f86d881552c55dccd0662b530836b
Reviewed-on: https://go-review.googlesource.com/99735
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 3db791cb4a..e6808ac023 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -710,7 +710,17 @@ type _defer struct { link *_defer } -// panics +// A _panic holds information about an active panic. +// +// This is marked go:notinheap because _panic values must only ever +// live on the stack. +// +// The argp and link fields are stack pointers, but don't need special +// handling during stack growth: because they are pointer-typed and +// _panic values only live on the stack, regular stack pointer +// adjustment takes care of them. +// +//go:notinheap type _panic struct { argp unsafe.Pointer // pointer to arguments of deferred call run during panic; cannot move - known to liblink arg interface{} // argument to panic |
