diff options
author | Nikhil Benesch <nikhil.benesch@gmail.com> | 2020-10-10 16:26:54 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-10-14 17:00:02 -0700 |
commit | 28774a6015261a100c426d206154a98c0ca215ce (patch) | |
tree | ad3b60f0105e975e97263df0445d364ea40226f8 /libgo | |
parent | 14d83c6f584c321989b43526dc9437de4381aa47 (diff) | |
download | gcc-28774a6015261a100c426d206154a98c0ca215ce.zip gcc-28774a6015261a100c426d206154a98c0ca215ce.tar.gz gcc-28774a6015261a100c426d206154a98c0ca215ce.tar.bz2 |
libgo: print reason code if throwing unwind exception fails
Calls to _Unwind_RaiseException and friends *can* return due to bugs in
libgo or memory corruption. When this occurs, print a message to stderr
with the reason code before aborting to aid debugging.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/261257
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/go-unwind.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c index ad3142c..16e0525 100644 --- a/libgo/runtime/go-unwind.c +++ b/libgo/runtime/go-unwind.c @@ -59,20 +59,22 @@ void rethrowException () { struct _Unwind_Exception *hdr; + _Unwind_Reason_Code reason; hdr = (struct _Unwind_Exception *) runtime_g()->exception; #ifdef __USING_SJLJ_EXCEPTIONS__ - _Unwind_SjLj_Resume_or_Rethrow (hdr); + reason = _Unwind_SjLj_Resume_or_Rethrow (hdr); #else #if defined(_LIBUNWIND_STD_ABI) - _Unwind_RaiseException (hdr); + reason = _Unwind_RaiseException (hdr); #else - _Unwind_Resume_or_Rethrow (hdr); + reason = _Unwind_Resume_or_Rethrow (hdr); #endif #endif /* Rethrowing the exception should not return. */ + runtime_printf ("failed to rethrow unwind exception (reason=%d)\n", reason); abort(); } @@ -105,6 +107,7 @@ throwException () { struct _Unwind_Exception *hdr; uintptr align; + _Unwind_Reason_Code reason; hdr = (struct _Unwind_Exception *)runtime_g ()->exception; @@ -119,12 +122,13 @@ throwException () hdr->exception_cleanup = NULL; #ifdef __USING_SJLJ_EXCEPTIONS__ - _Unwind_SjLj_RaiseException (hdr); + reason = _Unwind_SjLj_RaiseException (hdr); #else - _Unwind_RaiseException (hdr); + reason = _Unwind_RaiseException (hdr); #endif /* Raising an exception should not return. */ + runtime_printf ("failed to throw unwind exception (reason=%d)\n", reason); abort (); } |