Function __mingw_SEH_error_handler() is native Windows SEH handler and so
it returns EXCEPTION_DISPOSITION. Replace magic numeric values by proper
enum values from EXCEPTION_DISPOSITION. Note that enum EXCEPTION_DISPOSITION
has CamelCase constants, not the UPPER_CASE constants which were in
comments and have different values.

Instead of numeric value 4 (which just throw STATUS_INVALID_DISPOSITION),
return default action ExceptionContinueSearch. Same behavior for these
cases is in the _gnu_exception_handler() CRT handler which also continues
searching for another handler. Note that _gnu_exception_handler() is CRT
handler and hence returns UPPER_CASE constants with different numeric values.
---
 mingw-w64-crt/crt/crt_handler.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/mingw-w64-crt/crt/crt_handler.c b/mingw-w64-crt/crt/crt_handler.c
index 6e0f85af568e..4564d6df396d 100644
--- a/mingw-w64-crt/crt/crt_handler.c
+++ b/mingw-w64-crt/crt/crt_handler.c
@@ -82,7 +82,7 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* 
ExceptionRecord,
                           struct _CONTEXT* ContextRecord __attribute__ 
((unused)),
                           void *DispatcherContext __attribute__ ((unused)))
 {
-  EXCEPTION_DISPOSITION action = ExceptionContinueSearch; /* 
EXCEPTION_CONTINUE_SEARCH; */
+  EXCEPTION_DISPOSITION action = ExceptionContinueSearch;
   void (*old_handler) (int);
   int reset_fpu = 0;
 
@@ -96,16 +96,14 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* 
ExceptionRecord,
          /* this is undefined if the signal was raised by anything other
             than raise ().  */
          signal (SIGSEGV, SIG_IGN);
-         action = 0; //EXCEPTION_CONTINUE_EXECUTION;
+         action = ExceptionContinueExecution;
        }
       else if (old_handler != SIG_DFL)
        {
          /* This means 'old' is a user defined function. Call it */
          (*old_handler) (SIGSEGV);
-         action = 0; // EXCEPTION_CONTINUE_EXECUTION;
+         action = ExceptionContinueExecution;
        }
-      else
-        action = 4; /* EXCEPTION_EXECUTE_HANDLER; */
       break;
     case EXCEPTION_ILLEGAL_INSTRUCTION:
     case EXCEPTION_PRIV_INSTRUCTION:
@@ -116,16 +114,14 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* 
ExceptionRecord,
          /* this is undefined if the signal was raised by anything other
             than raise ().  */
          signal (SIGILL, SIG_IGN);
-         action = 0; // EXCEPTION_CONTINUE_EXECUTION;
+         action = ExceptionContinueExecution;
        }
       else if (old_handler != SIG_DFL)
        {
          /* This means 'old' is a user defined function. Call it */
          (*old_handler) (SIGILL);
-         action = 0; // EXCEPTION_CONTINUE_EXECUTION;
+         action = ExceptionContinueExecution;
        }
-      else
-        action = 4; /* EXCEPTION_EXECUTE_HANDLER;*/
       break;
     case EXCEPTION_FLT_INVALID_OPERATION:
     case EXCEPTION_FLT_DIVIDE_BY_ZERO:
@@ -144,13 +140,13 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* 
ExceptionRecord,
          signal (SIGFPE, SIG_IGN);
          if (reset_fpu)
            _fpreset ();
-         action = 0; // EXCEPTION_CONTINUE_EXECUTION;
+         action = ExceptionContinueExecution;
        }
       else if (old_handler != SIG_DFL)
        {
          /* This means 'old' is a user defined function. Call it */
          (*old_handler) (SIGFPE);
-         action = 0; // EXCEPTION_CONTINUE_EXECUTION;
+         action = ExceptionContinueExecution;
        }
       break;
     case EXCEPTION_DATATYPE_MISALIGNMENT:
@@ -159,7 +155,7 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* 
ExceptionRecord,
     case EXCEPTION_INT_OVERFLOW:
     case EXCEPTION_INVALID_HANDLE:
     /*case EXCEPTION_POSSIBLE_DEADLOCK: */
-      action = 0; // EXCEPTION_CONTINUE_EXECUTION;
+      action = ExceptionContinueExecution;
       break;
     default:
       break;
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to