Cygwin: main exception handler (64-bit): continue GCC exceptions

This is necessary in order to be consistent with the following comment
in the definition of _Unwind_RaiseException() in the GCC source file
libgcc/unwind-seh.c:

     The exception handler installed in crt0 will continue any GCC
     exception that reaches there (and isn't marked non-continuable).

Previously we failed to do this and, as a consequence, the C++ runtime
didn't call std::terminate after an unhandled exception.

This fixes the problem reported here:

  https://cygwin.com/pipermail/cygwin/2019-October/242795.html
  https://sourceware.org/pipermail/cygwin/2020-August/245897.html
This commit is contained in:
Ken Brown 2020-08-17 16:24:59 -04:00
parent 8a7ec55c53
commit 74cf7dabcb
2 changed files with 23 additions and 0 deletions

View File

@ -762,6 +762,25 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in,
handling. */
return ExceptionContinueExecution;
#ifdef __x86_64__
/* From the GCC source file libgcc/unwind-seh.c. */
#define STATUS_USER_DEFINED (1U << 29)
#define GCC_MAGIC (('G' << 16) | ('C' << 8) | 'C')
#define GCC_EXCEPTION(TYPE) \
(STATUS_USER_DEFINED | ((TYPE) << 24) | GCC_MAGIC)
#define STATUS_GCC_THROW GCC_EXCEPTION (0)
#define STATUS_GCC_UNWIND GCC_EXCEPTION (1)
#define STATUS_GCC_FORCED GCC_EXCEPTION (2)
case STATUS_GCC_THROW:
case STATUS_GCC_UNWIND:
case STATUS_GCC_FORCED:
/* According to a comment in the GCC function
_Unwind_RaiseException(), GCC expects us to continue all the
(continuable) GCC exceptions that reach us. */
return ExceptionContinueExecution;
#endif
default:
/* If we don't recognize the exception, we have to assume that
we are doing structured exception handling, and we let

View File

@ -11,3 +11,7 @@ Bug Fixes:
- Fix an mmap issue that could cause failure with errno EFBIG
Partially addresses: https://sourceware.org/pipermail/cygwin/2020-July/245557.html
- Fix the behavior of C++ apps after an unhandled exception (64-bit only)
Addresses: https://cygwin.com/pipermail/cygwin/2019-October/242795.html
https://cygwin.com/pipermail/cygwin/2020-August/245897.html