From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id B6C263857C4D; Tue, 18 Aug 2020 11:05:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6C263857C4D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: main exception handler (64-bit): continue GCC exceptions X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: 8a7ec55c535cddd74d45a2f6fb644ecded114de8 X-Git-Newrev: 74cf7dabcb69ea0608163ba84ecc3d798d5b0421 Message-Id: <20200818110518.B6C263857C4D@sourceware.org> Date: Tue, 18 Aug 2020 11:05:18 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Aug 2020 11:05:18 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=74cf7dabcb69ea0608163ba84ecc3d798d5b0421 commit 74cf7dabcb69ea0608163ba84ecc3d798d5b0421 Author: Ken Brown Date: Mon Aug 17 16:24:59 2020 -0400 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 Diff: --- winsup/cygwin/exceptions.cc | 19 +++++++++++++++++++ winsup/cygwin/release/3.1.7 | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 0d9e8f70e..61406e5d1 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -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 diff --git a/winsup/cygwin/release/3.1.7 b/winsup/cygwin/release/3.1.7 index 2f4856495..83cff2b46 100644 --- a/winsup/cygwin/release/3.1.7 +++ b/winsup/cygwin/release/3.1.7 @@ -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