mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
Merge branch 'fix-w32-csharp-exception-handling' into 'master'
Fix win32 C# exception handling when running inside a debugger Closes #2025 See merge request GNOME/glib!1373
This commit is contained in:
commit
167fbe5be9
@ -1071,7 +1071,8 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
|
|||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
|
|
||||||
if (ExceptionInfo == NULL ||
|
if (ExceptionInfo == NULL ||
|
||||||
ExceptionInfo->ExceptionRecord == NULL)
|
ExceptionInfo->ExceptionRecord == NULL ||
|
||||||
|
IsDebuggerPresent ())
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
er = ExceptionInfo->ExceptionRecord;
|
er = ExceptionInfo->ExceptionRecord;
|
||||||
@ -1081,7 +1082,6 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
|
|||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
case EXCEPTION_STACK_OVERFLOW:
|
case EXCEPTION_STACK_OVERFLOW:
|
||||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||||
case EXCEPTION_BREAKPOINT: /* DebugBreak() raises this */
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
catch_list = getenv ("G_VEH_CATCH");
|
catch_list = getenv ("G_VEH_CATCH");
|
||||||
@ -1109,17 +1109,6 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
|
|||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDebuggerPresent ())
|
|
||||||
{
|
|
||||||
/* This shouldn't happen, but still try to
|
|
||||||
* avoid recursion with EXCEPTION_BREAKPOINT and
|
|
||||||
* DebugBreak().
|
|
||||||
*/
|
|
||||||
if (er->ExceptionCode != EXCEPTION_BREAKPOINT)
|
|
||||||
DebugBreak ();
|
|
||||||
return EXCEPTION_CONTINUE_EXECUTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf_s (stderr,
|
fprintf_s (stderr,
|
||||||
"Exception code=0x%lx flags=0x%lx at 0x%p",
|
"Exception code=0x%lx flags=0x%lx at 0x%p",
|
||||||
er->ExceptionCode,
|
er->ExceptionCode,
|
||||||
@ -1219,6 +1208,14 @@ g_crash_handler_win32_init (void)
|
|||||||
if (WinVEH_handle != NULL)
|
if (WinVEH_handle != NULL)
|
||||||
return;
|
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);
|
WinVEH_handle = AddVectoredExceptionHandler (0, &g_win32_veh_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user