Bug 1247453 - part 1 - request synchronization privileges in kill_pid; r=gbrown
authorNathan Froyd <froydnj@mozilla.com>
Mon, 04 Feb 2019 11:19:36 -0500
changeset 456648 072ba80a8f3e8ef7e52949bcbed9269c2a02c072
parent 456647 1fcffb8130e8c5966b8270943a5792ef7027e4dd
child 456649 9fb802aba6b9167ce4ecc0bd3a30704aeb3fb7ae
push id35499
push userccoroiu@mozilla.com
push dateMon, 04 Feb 2019 21:42:59 +0000
treeherdermozilla-central@a27965fa7374 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1247453
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1247453 - part 1 - request synchronization privileges in kill_pid; r=gbrown Windows documentation indicates that it's invalid to WaitForSingleObject on a process handle unless you request the SYNCHRONIZE access right. And indeed, we see errors in the logs like: 09:58:28 WARNING - mozcrash kill_pid(): wait failed (-1) terminating pid 6340: error 5 That "error 5" is an ERROR_ACCESS_DENIED code. Such errors should go away with requesting the proper access rights. Credit to dmajor for noticing the discrepancy.
testing/mozbase/mozcrash/mozcrash/mozcrash.py
--- a/testing/mozbase/mozcrash/mozcrash/mozcrash.py
+++ b/testing/mozbase/mozcrash/mozcrash/mozcrash.py
@@ -473,20 +473,21 @@ if mozinfo.isWin:
 
     def kill_pid(pid):
         """
         Terminate a process with extreme prejudice.
 
         :param pid: PID of the process to terminate.
         """
         PROCESS_TERMINATE = 0x0001
+        SYNCHRONIZE = 0x00100000
         WAIT_OBJECT_0 = 0x0
         WAIT_FAILED = -1
         logger = get_logger()
-        handle = OpenProcess(PROCESS_TERMINATE, 0, pid)
+        handle = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, 0, pid)
         if handle:
             if kernel32.TerminateProcess(handle, 1):
                 # TerminateProcess is async; wait up to 30 seconds for process to
                 # actually terminate, then give up so that clients are not kept
                 # waiting indefinitely for hung processes.
                 status = kernel32.WaitForSingleObject(handle, 30000)
                 if status == WAIT_FAILED:
                     err = kernel32.GetLastError()