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

2020-08-17 Thread Ken Brown via Cygwin-patches
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://sourceware.org/pipermail/cygwin/2020-August/245897.html
---
 winsup/cygwin/exceptions.cc | 21 +
 1 file changed, 21 insertions(+)

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 0d9e8f70e..f8da7529b 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -647,6 +647,17 @@ exception::handle (EXCEPTION_RECORD *e, exception_list 
*frame, CONTEXT *in,
   if (exit_state || e->ExceptionFlags)
 return ExceptionContinueSearch;
 
+/* From the GCC source file libgcc/unwind-seh.c. */
+#ifdef __x86_64__
+#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)
+#endif
+
   siginfo_t si = {};
   si.si_code = SI_KERNEL;
   /* Coerce win32 value to posix value.  */
@@ -762,6 +773,16 @@ exception::handle (EXCEPTION_RECORD *e, exception_list 
*frame, CONTEXT *in,
 handling.  */
   return ExceptionContinueExecution;
 
+#ifdef __x86_64__
+  /* According to a comment in the GCC function
+_Unwind_RaiseException(), GCC expects us to continue all the
+(continuable) GCC exceptions that reach us. */
+case STATUS_GCC_THROW:
+case STATUS_GCC_UNWIND:
+case STATUS_GCC_FORCED:
+  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
-- 
2.28.0



Re: [PATCH] Cygwin: pty: Change the timing of set_locale() call again.

2020-08-17 Thread Corinna Vinschen
On Aug 15 12:23, Takashi Yano via Cygwin-patches wrote:
> - After commit 095972ce5b1d319915501a7e381802914bed790c, charset
>   conversion in mintty is broken if charset is set to other than
>   UTF-8. This seems to be caused because mintty does not set locale
>   yet at fork() call. This patch changes the timing of set_locale()
>   call again to avoid this issue.
> ---
>  winsup/cygwin/fhandler_tty.cc | 10 ++
>  winsup/cygwin/spawn.cc| 12 
>  2 files changed, 18 insertions(+), 4 deletions(-)

Pushed.


Thanks,
Corinna