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); }