[glib/glib-2-62: 2/3] gwin32: Do not register a crash handler unless requested



commit 3a3b99dd5263075630130ec7071b9ae4ec8591c9
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Tue Feb 18 23:04:39 2020 +0530

    gwin32: Do not register a crash handler unless requested
    
    Fixes https://gitlab.gnome.org/GNOME/glib/issues/2025

 glib/gwin32.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/glib/gwin32.c b/glib/gwin32.c
index 297c58e7a..2f2fe05a8 100644
--- a/glib/gwin32.c
+++ b/glib/gwin32.c
@@ -1208,6 +1208,14 @@ g_crash_handler_win32_init (void)
   if (WinVEH_handle != NULL)
     return;
 
+  /* Do not register an exception handler if we're not supposed to catch any
+   * exceptions. Exception handlers are considered dangerous to use, and can
+   * break advanced exception handling such as in CLRs like C# or other managed
+   * code. See: 
https://blogs.msdn.microsoft.com/jmstall/2006/05/24/beware-of-the-vectored-exception-handler-and-managed-code/
+   */
+  if (getenv ("G_DEBUGGER") == NULL && getenv("G_VEH_CATCH") == NULL)
+    return;
+
   WinVEH_handle = AddVectoredExceptionHandler (0, &g_win32_veh_handler);
 }
 


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