[gimp] Issue #2794 - Gimp crash just on File Open and Edit Preferences



commit 679fd5f23105f4dc3f4de140fa82470731bc9acf
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 28 11:55:59 2019 +0200

    Issue #2794 - Gimp crash just on File Open and Edit Preferences
    
    As suggested by LRN, change gimp_sigfatal_handler() on Windows to
    dstinguish between fatal and non-fatal exceptions so we don't abort on
    each minor hickup.

 app/Makefile.am |  6 +++++-
 app/signals.c   | 26 ++++++++++++++++++++------
 2 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index bd8dae85d3..5e4872d146 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -99,6 +99,9 @@ libpsapi = -lpsapi
 # for GimpBacktrace
 libdbghelp = -ldbghelp
 
+# for I_RpcExceptionFilter()
+librpcrt4 = -lrpcrt4
+
 if HAVE_EXCHNDL
 exchndl = -lexchndl
 endif
@@ -198,7 +201,8 @@ gimpconsoleldadd = \
        $(libm)                                                 \
        $(libdl)                                                \
        $(libpsapi)                                             \
-       $(libdbghelp)
+       $(libdbghelp)                                           \
+       $(librpcrt4)
 
 gimp_@GIMP_APP_VERSION@_LDFLAGS = \
        $(AM_LDFLAGS)                                           \
diff --git a/app/signals.c b/app/signals.c
index c242cea840..26ea6831f0 100644
--- a/app/signals.c
+++ b/app/signals.c
@@ -126,13 +126,27 @@ gimp_init_signal_handlers (gchar **backtrace_file)
 static LONG WINAPI
 gimp_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo)
 {
-  /* Just in case, so that we don't loop or anything similar, just
-   * re-establish previous handler.
-   */
-  SetUnhandledExceptionFilter (g_prevExceptionFilter);
+  EXCEPTION_RECORD *er;
+  int               fatal;
+
+  if (pExceptionInfo == NULL ||
+      pExceptionInfo->ExceptionRecord == NULL)
+    return EXCEPTION_CONTINUE_SEARCH;
+
+  er = pExceptionInfo->ExceptionRecord;
+  fatal = I_RpcExceptionFilter (er->ExceptionCode);
 
-  /* Now process the exception. */
-  gimp_fatal_error ("unhandled exception");
+  /* IREF() returns EXCEPTION_CONTINUE_SEARCH for fatal exceptions */
+  if (fatal == EXCEPTION_CONTINUE_SEARCH)
+    {
+      /* Just in case, so that we don't loop or anything similar, just
+       * re-establish previous handler.
+       */
+      SetUnhandledExceptionFilter (g_prevExceptionFilter);
+
+      /* Now process the exception. */
+      gimp_fatal_error ("unhandled exception");
+    }
 
   if (g_prevExceptionFilter && g_prevExceptionFilter != gimp_sigfatal_handler)
     return g_prevExceptionFilter (pExceptionInfo);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]