]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: make throw safer to call
authorAustin Clements <austin@google.com>
Fri, 12 Jan 2018 17:39:22 +0000 (12:39 -0500)
committerAustin Clements <austin@google.com>
Thu, 8 Mar 2018 22:55:52 +0000 (22:55 +0000)
commit7f1b2738bb7a8863ee78d5357acbc820b7083821
treed677547399574e29efe3fdd4b0d2d87cb566f6d9
parent9d59234cbe55c32b6b64969a4360ecccfce582fd
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>
14 files changed:
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_amd64p32.s
src/runtime/asm_arm.s
src/runtime/asm_arm64.s
src/runtime/asm_mips64x.s
src/runtime/asm_mipsx.s
src/runtime/asm_ppc64x.s
src/runtime/asm_s390x.s
src/runtime/cgocheck.go
src/runtime/panic.go
src/runtime/proc.go
src/runtime/stack.go
src/runtime/stubs.go