public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: main exception handler (64-bit): continue GCC exceptions Date: Tue, 18 Aug 2020 11:05:18 +0000 (GMT) [thread overview] Message-ID: <20200818110518.B6C263857C4D@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=74cf7dabcb69ea0608163ba84ecc3d798d5b0421 commit 74cf7dabcb69ea0608163ba84ecc3d798d5b0421 Author: Ken Brown <kbrown@cornell.edu> 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
reply other threads:[~2020-08-18 11:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200818110518.B6C263857C4D@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).