• Austin Clements's avatar
    runtime: make throw safer to call · 7f1b2738
    Austin Clements authored
    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: 's avatarKeith Randall <khr@golang.org>
    7f1b2738
cgocheck.go 6.57 KB