runtime: improve handling of panic during deferred function

When a panic occurs while processing a deferred function that
recovered an earlier panic, we shouldn't report the recovered panic
in the panic stack trace. Stop doing so by keeping track of the panic
that triggered a defer, marking it as aborted if we see the defer again,
and discarding aborted panics when a panic is recovered. This is what
the gc runtime does.

The test for this is TestRecursivePanic in runtime/crash_test.go.
We don't run that test yet, but we will soon.

Change-Id: Idbfd4cca731116cd620c7012499c3c9ec8065ff2
Reviewed-on: https://go-review.googlesource.com/46461
Reviewed-by: Than McIntosh <thanm@google.com>
2 files changed