diff options
| author | Austin Clements <austin@google.com> | 2018-01-12 12:39:22 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-03-08 22:55:52 +0000 |
| commit | 7f1b2738bb7a8863ee78d5357acbc820b7083821 (patch) | |
| tree | d677547399574e29efe3fdd4b0d2d87cb566f6d9 /src/runtime/stack.go | |
| parent | 9d59234cbe55c32b6b64969a4360ecccfce582fd (diff) | |
| download | go-7f1b2738bb7a8863ee78d5357acbc820b7083821.tar.xz | |
runtime: make throw safer to call
Currently, throw may grow the stack, which means whenever we call it
from a context where it's not safe to grow the stack, we first have to
switch to the system stack. This is pretty easy to get wrong.
Fix this by making throw switch to the system stack so it doesn't grow
the stack and is hence safe to call without a system stack switch at
the call site.
The only thing this complicates is badsystemstack itself, which would
now go into an infinite loop before printing anything (previously it
would also go into an infinite loop, but would at least print the
error first). Fix this by making badsystemstack do a direct write and
then crash hard.
Change-Id: Ic5b4a610df265e47962dcfa341cabac03c31c049
Reviewed-on: https://go-review.googlesource.com/93659
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/stack.go')
| -rw-r--r-- | src/runtime/stack.go | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/runtime/stack.go b/src/runtime/stack.go index b5dda0d9e6..5a6259c6e2 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1184,7 +1184,5 @@ func freeStackSpans() { //go:nosplit func morestackc() { - systemstack(func() { - throw("attempt to execute system stack code on user stack") - }) + throw("attempt to execute system stack code on user stack") } |
