Bug 1431803 Disable a specific __try block on MinGW r?bobowen draft
authorTom Ritter <tom@mozilla.com>
Fri, 19 Jan 2018 13:26:22 -0600
changeset 749420 e300ccea45351e9d6e999f00c645277283c55cc1
parent 749419 180e548303f5dfcec6466015c01f82e505976a02
push id97395
push userbmo:tom@mozilla.com
push dateWed, 31 Jan 2018 13:18:51 +0000
reviewersbobowen
bugs1431803
milestone60.0a1
Bug 1431803 Disable a specific __try block on MinGW r?bobowen This function is a technique to name a thread for debugging purposes, and it always throws an exception (and then continues). On MinGW we don't want it to throw an exception, so we do nothing. This means on MinGW we won't get nice thread naming during debugging, but we'll limp along. MozReview-Commit-ID: JRKY4wp7sdu
security/sandbox/chromium-shim/patches/with_update/mingw_disable_one_try.patch
security/sandbox/chromium-shim/patches/with_update/patch_order.txt
security/sandbox/chromium/base/threading/platform_thread_win.cc
new file mode 100644
--- /dev/null
+++ b/security/sandbox/chromium-shim/patches/with_update/mingw_disable_one_try.patch
@@ -0,0 +1,51 @@
+# HG changeset patch
+# User Tom Ritter <tom@mozilla.com>
+# Date 1516389982 21600
+#      Fri Jan 19 13:26:22 2018 -0600
+# Node ID 3ca7306d73ebc1ce47ccdc62ee8cbb69a9bfbb2c
+# Parent  6aa6c7d894609140ccde2e9e50eba8c25a9caeb5
+Bug 1431803 Disable a specific __try block on MinGW r?bobowen
+
+This function is a technique to name a thread for debugging purposes,
+and it always throws an exception (and then continues). On MinGW
+we don't want it to throw an exception, so we do nothing.
+
+This means on MinGW we won't get nice thread naming during debugging,
+but we'll limp along.
+
+MozReview-Commit-ID: JRKY4wp7sdu
+
+diff --git a/security/sandbox/chromium/base/threading/platform_thread_win.cc b/security/sandbox/chromium/base/threading/platform_thread_win.cc
+--- a/security/sandbox/chromium/base/threading/platform_thread_win.cc
++++ b/security/sandbox/chromium/base/threading/platform_thread_win.cc
+@@ -32,27 +32,30 @@ typedef struct tagTHREADNAME_INFO {
+ } THREADNAME_INFO;
+ 
+ // The SetThreadDescription API was brought in version 1607 of Windows 10.
+ typedef HRESULT(WINAPI* SetThreadDescription)(HANDLE hThread,
+                                               PCWSTR lpThreadDescription);
+ 
+ // This function has try handling, so it is separated out of its caller.
+ void SetNameInternal(PlatformThreadId thread_id, const char* name) {
++  //This function is only used for debugging purposes, as you can find by its caller
++#ifndef __MINGW32__
+   THREADNAME_INFO info;
+   info.dwType = 0x1000;
+   info.szName = name;
+   info.dwThreadID = thread_id;
+   info.dwFlags = 0;
+ 
+   __try {
+     RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD),
+                    reinterpret_cast<DWORD_PTR*>(&info));
+   } __except(EXCEPTION_CONTINUE_EXECUTION) {
+   }
++#endif
+ }
+ 
+ struct ThreadParams {
+   PlatformThread::Delegate* delegate;
+   bool joinable;
+   ThreadPriority priority;
+ };
+ 
old mode 100644
new mode 100755
--- a/security/sandbox/chromium-shim/patches/with_update/patch_order.txt
+++ b/security/sandbox/chromium-shim/patches/with_update/patch_order.txt
@@ -12,9 +12,10 @@ fix_Wcomma_warning_in_time_cc.patch
 allow_read_only_all_paths_rule.patch
 revert_TargetNtSetInformationThread_change.patch
 mingw_base_win_get_caller.patch
 mingw_duplicate_instatinations.patch
 mingw_msvc_requirement_error.patch
 mingw_copy_s.patch
 mingw_operator_new.patch
 mingw_cast_getprocaddress.patch
-mingw_capitalization.patch
\ No newline at end of file
+mingw_capitalization.patch
+mingw_disable_one_try.patch
\ No newline at end of file
--- a/security/sandbox/chromium/base/threading/platform_thread_win.cc
+++ b/security/sandbox/chromium/base/threading/platform_thread_win.cc
@@ -32,27 +32,30 @@ typedef struct tagTHREADNAME_INFO {
 } THREADNAME_INFO;
 
 // The SetThreadDescription API was brought in version 1607 of Windows 10.
 typedef HRESULT(WINAPI* SetThreadDescription)(HANDLE hThread,
                                               PCWSTR lpThreadDescription);
 
 // This function has try handling, so it is separated out of its caller.
 void SetNameInternal(PlatformThreadId thread_id, const char* name) {
+  //This function is only used for debugging purposes, as you can find by its caller
+#ifndef __MINGW32__
   THREADNAME_INFO info;
   info.dwType = 0x1000;
   info.szName = name;
   info.dwThreadID = thread_id;
   info.dwFlags = 0;
 
   __try {
     RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD),
                    reinterpret_cast<DWORD_PTR*>(&info));
   } __except(EXCEPTION_CONTINUE_EXECUTION) {
   }
+#endif
 }
 
 struct ThreadParams {
   PlatformThread::Delegate* delegate;
   bool joinable;
   ThreadPriority priority;
 };