Bug 1377605 Cast -1 to DWORD to correctly match the error return value given by SuspendThread r?aklotz draft
authorTom Ritter <tom@mozilla.com>
Mon, 03 Jul 2017 16:07:25 -0500
changeset 603354 f6f408e2349ba45a539117f62e16d3351a2e1bb6
parent 602959 0f7c4b736c752897177dcffe796fa788e1f3fb7c
child 603440 d7077a2e46d206206ec30bb2d3abb77d0ca948df
push id66771
push userbmo:tom@mozilla.com
push dateMon, 03 Jul 2017 21:08:19 +0000
reviewersaklotz
bugs1377605
milestone56.0a1
Bug 1377605 Cast -1 to DWORD to correctly match the error return value given by SuspendThread r?aklotz MozReview-Commit-ID: 5XHgkpQJQKY
js/src/wasm/WasmSignalHandlers.cpp
mozglue/misc/StackWalk.cpp
xpcom/threads/HangMonitor.cpp
old mode 100644
new mode 100755
--- a/js/src/wasm/WasmSignalHandlers.cpp
+++ b/js/src/wasm/WasmSignalHandlers.cpp
@@ -1585,17 +1585,17 @@ js::InterruptRunningJitCode(JSContext* c
     // We are not on the runtime's active thread, so to do 1 and 2 above, we need
     // to halt the runtime's active thread first.
 #if defined(XP_WIN)
     // On Windows, we can simply suspend the active thread and work directly on
     // its context from this thread. SuspendThread can sporadically fail if the
     // thread is in the middle of a syscall. Rather than retrying in a loop,
     // just wait for the next request for interrupt.
     HANDLE thread = (HANDLE)cx->threadNative();
-    if (SuspendThread(thread) != -1) {
+    if (SuspendThread(thread) != (DWORD)-1) {
         CONTEXT context;
         context.ContextFlags = CONTEXT_FULL;
         if (GetThreadContext(thread, &context)) {
             if (RedirectJitCodeToInterruptCheck(cx, &context))
                 SetThreadContext(thread, &context);
         }
         ResumeThread(thread);
     }
--- a/mozglue/misc/StackWalk.cpp
+++ b/mozglue/misc/StackWalk.cpp
@@ -581,23 +581,23 @@ WalkStackThread(void* aData)
       ret = ::WaitForSingleObject(data->eventStart, INFINITE);
       if (ret != WAIT_OBJECT_0) {
         PrintError("WaitForSingleObject");
       }
 
       // Suspend the calling thread, dump his stack, and then resume him.
       // He's currently waiting for us to finish so now should be a good time.
       ret = ::SuspendThread(data->thread);
-      if (ret == -1) {
+      if (ret == (DWORD)-1) {
         PrintError("ThreadSuspend");
       } else {
         WalkStackMain64(data);
 
         ret = ::ResumeThread(data->thread);
-        if (ret == -1) {
+        if (ret == (DWORD)-1) {
           PrintError("ThreadResume");
         }
       }
 
       ::SetEvent(data->eventEnd);
     }
   }
 
old mode 100644
new mode 100755
--- a/xpcom/threads/HangMonitor.cpp
+++ b/xpcom/threads/HangMonitor.cpp
@@ -146,17 +146,17 @@ GetChromeHangReport(Telemetry::Processed
 
   // The thread we're about to suspend might have the alloc lock
   // so allocate ahead of time
   std::vector<uintptr_t> rawStack;
   rawStack.reserve(MAX_CALL_STACK_PCS);
 
   DWORD ret = ::SuspendThread(winMainThreadHandle);
   bool suspended = false;
-  if (ret != -1) {
+  if (ret != (DWORD)-1) {
     // SuspendThread is asynchronous, so the thread may still be running. Use
     // GetThreadContext to ensure it's really suspended.
     // See https://blogs.msdn.microsoft.com/oldnewthing/20150205-00/?p=44743.
     CONTEXT context;
     context.ContextFlags = CONTEXT_CONTROL;
     if (::GetThreadContext(winMainThreadHandle, &context)) {
       suspended = true;
     }