mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
gthread-win32: No need to raise thread name exception if the debugger is not present
As outlined in [1], raising the exception without a debugger attached isn't of any use, as the thread name won't be stored anywhere. The system doesn't trap such exception, only debuggers. This also fixes a TOCTTOU issue between the IsDebuggerPresent() check and the RaiseException() call. References: [1] - https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2022#set-a-thread-name-by-throwing-an-exception
This commit is contained in:
parent
fb3f1733c3
commit
f4b53cacbf
@ -605,10 +605,7 @@ SetThreadName (DWORD dwThreadID,
|
||||
{
|
||||
}
|
||||
#else
|
||||
/* Without a debugger we *must* have an exception handler,
|
||||
* otherwise raising an exception will crash the process.
|
||||
*/
|
||||
if ((!IsDebuggerPresent ()) && (SetThreadName_VEH_handle == NULL))
|
||||
if ((!IsDebuggerPresent ()) || (SetThreadName_VEH_handle == NULL))
|
||||
return;
|
||||
|
||||
RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize, (const ULONG_PTR *) &info);
|
||||
|
Loading…
Reference in New Issue
Block a user