mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-30 13:26:10 +08:00
winpthreads: do not use the XXXExceptionHandler API in winstore builds
Calling RemoveVectoredExceptionHandler()/AddVectoredExceptionHandler() is forbidden in non-desktop apps. https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-addvectoredexceptionhandler https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-removevectoredexceptionhandler If USE_VEH_FOR_MSC_SETTHREADNAME is set in winstore builds, RaiseException is only called if there's a debugger attached. In non-winstore builds it can also be called if the SetThreadName_VEH_handle was set succesfully. Signed-off-by: Liu Hao <lh_mouse@126.com>
This commit is contained in:
parent
d58069b138
commit
01385c6aaa
@ -57,6 +57,10 @@ static pthread_t idListNextId = 0;
|
||||
#if !defined(_MSC_VER)
|
||||
#define USE_VEH_FOR_MSC_SETTHREADNAME
|
||||
#endif
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
/* forbidden RemoveVectoredExceptionHandler/AddVectoredExceptionHandler APIs */
|
||||
#undef USE_VEH_FOR_MSC_SETTHREADNAME
|
||||
#endif
|
||||
|
||||
#if defined(USE_VEH_FOR_MSC_SETTHREADNAME)
|
||||
static void *SetThreadName_VEH_handle = NULL;
|
||||
@ -105,7 +109,11 @@ SetThreadName (DWORD dwThreadID, LPCSTR szThreadName)
|
||||
/* Without a debugger we *must* have an exception handler,
|
||||
* otherwise raising an exception will crash the process.
|
||||
*/
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
if ((!IsDebuggerPresent ()) && (SetThreadName_VEH_handle == NULL))
|
||||
#else
|
||||
if (!IsDebuggerPresent ())
|
||||
#endif
|
||||
return;
|
||||
|
||||
RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize, (ULONG_PTR *) &info);
|
||||
|
Loading…
Reference in New Issue
Block a user