runtime: allocate _panic struct on heap
commit29201b552c46da2eb8a80f56a8bb52d773431439
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2016 15:54:30 +0000 (8 15:54 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2016 15:54:30 +0000 (8 15:54 +0000)
tree6975dcd13003606feee2cb8d7753ef271c391a97
parent98fc1fdc0a9790efa8febb2c3b8c38b25c903df9
runtime: allocate _panic struct on heap

    The gc library allocates a _panic struct on the stack. This does not
    work for gccgo, because when a deferred function recovers the panic we
    unwind the stack up to that point so that returning from the function
    will work correctly.

    Allocating on the stack fine if the panic is not recovered, and it
    works fine if the panic is recovered by a function that
    returns. However, it fails if the panic is recovered by a function
    that itself panics, and if that second panic is then recovered by a
    function higher up on the stack. When we unwind the stack to that
    second panic, the g will wind up pointing at a panic farther down on
    the stack. Even then everything will often work fine, except when the
    deferred function catching the second panic makes a bunch of calls
    that use stack space before returning. In that case the code can
    overwrite the panic struct, which will then cause disaster when we
    remove the struct from the linked list, as the link field will be
    garbage. This case is rare enough that all the x86 tests were passing,
    but there was a failure on ppc64le.

    Before https://golang.org/cl/33414 we allocated the panic struct on
    the heap, so go back to doing that again.

    Fixes golang/go#18228.

    Reviewed-on: https://go-review.googlesource.com/34027

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243444 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/go/gofrontend/MERGE
libgo/go/runtime/panic.go