1# HG changeset patch
2# User Tom Ritter <tom@mozilla.com>
3# Date 1516389982 21600
4#      Fri Jan 19 13:26:22 2018 -0600
5# Node ID 3ca7306d73ebc1ce47ccdc62ee8cbb69a9bfbb2c
6# Parent  6aa6c7d894609140ccde2e9e50eba8c25a9caeb5
7Bug 1431803 Disable a specific __try block on MinGW r?bobowen
8
9This function is a technique to name a thread for debugging purposes,
10and it always throws an exception (and then continues). On MinGW
11we don't want it to throw an exception, so we do nothing.
12
13This means on MinGW we won't get nice thread naming during debugging,
14but we'll limp along.
15
16MozReview-Commit-ID: JRKY4wp7sdu
17
18diff --git a/security/sandbox/chromium/base/threading/platform_thread_win.cc b/security/sandbox/chromium/base/threading/platform_thread_win.cc
19--- a/security/sandbox/chromium/base/threading/platform_thread_win.cc
20+++ b/security/sandbox/chromium/base/threading/platform_thread_win.cc
21@@ -32,27 +32,30 @@ typedef struct tagTHREADNAME_INFO {
22 } THREADNAME_INFO;
23
24 // The SetThreadDescription API was brought in version 1607 of Windows 10.
25 typedef HRESULT(WINAPI* SetThreadDescription)(HANDLE hThread,
26                                               PCWSTR lpThreadDescription);
27
28 // This function has try handling, so it is separated out of its caller.
29 void SetNameInternal(PlatformThreadId thread_id, const char* name) {
30+  //This function is only used for debugging purposes, as you can find by its caller
31+#ifndef __MINGW32__
32   THREADNAME_INFO info;
33   info.dwType = 0x1000;
34   info.szName = name;
35   info.dwThreadID = thread_id;
36   info.dwFlags = 0;
37
38   __try {
39     RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD),
40                    reinterpret_cast<DWORD_PTR*>(&info));
41   } __except(EXCEPTION_CONTINUE_EXECUTION) {
42   }
43+#endif
44 }
45
46 struct ThreadParams {
47   PlatformThread::Delegate* delegate;
48   bool joinable;
49   ThreadPriority priority;
50 };
51
52