mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Merge branch 'vectored-exception-handlers' into 'main'
Small fixes and cleanups for Vectored Exception Handlers See merge request GNOME/glib!3569
This commit is contained in:
commit
9f6b42af6e
@ -571,7 +571,7 @@ SetThreadName (DWORD dwThreadID,
|
|||||||
info.dwThreadID = dwThreadID;
|
info.dwThreadID = dwThreadID;
|
||||||
info.dwFlags = 0;
|
info.dwFlags = 0;
|
||||||
|
|
||||||
infosize = sizeof (info) / sizeof (DWORD);
|
infosize = sizeof (info) / sizeof (ULONG_PTR);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
__try
|
__try
|
||||||
@ -579,14 +579,12 @@ SetThreadName (DWORD dwThreadID,
|
|||||||
RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize,
|
RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize,
|
||||||
(const ULONG_PTR *) &info);
|
(const ULONG_PTR *) &info);
|
||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (GetExceptionCode () == EXCEPTION_SET_THREAD_NAME ?
|
||||||
|
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Without a debugger we *must* have an exception handler,
|
if ((!IsDebuggerPresent ()) || (SetThreadName_VEH_handle == NULL))
|
||||||
* otherwise raising an exception will crash the process.
|
|
||||||
*/
|
|
||||||
if ((!IsDebuggerPresent ()) && (SetThreadName_VEH_handle == NULL))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize, (const ULONG_PTR *) &info);
|
RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize, (const ULONG_PTR *) &info);
|
||||||
@ -659,11 +657,15 @@ g_thread_win32_init (void)
|
|||||||
InitializeCriticalSection (&g_private_lock);
|
InitializeCriticalSection (&g_private_lock);
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
SetThreadName_VEH_handle = AddVectoredExceptionHandler (1, &SetThreadName_VEH);
|
/* Set the handler as last to not interfere with ASAN runtimes.
|
||||||
|
* Many ASAN implementations (currently all three of GCC, CLANG
|
||||||
|
* and MSVC) install a Vectored Exception Handler that must be
|
||||||
|
* first in the sequence to work well
|
||||||
|
*/
|
||||||
|
SetThreadName_VEH_handle = AddVectoredExceptionHandler (0, &SetThreadName_VEH);
|
||||||
if (SetThreadName_VEH_handle == NULL)
|
if (SetThreadName_VEH_handle == NULL)
|
||||||
{
|
g_critical ("%s failed with error code %u",
|
||||||
/* This is bad, but what can we do? */
|
"AddVectoredExceptionHandler", (unsigned int) GetLastError ());
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user