Closed Bug 1501311 Opened 6 years ago Closed 4 years ago

With a debugger attached, debug builds laucher process hangs at shutdown (WaitForInputIdle always returns WAIT_FAILED and GetLastError() == ERROR_NOT_GUI_PROCESS)

Categories

(Core :: Widget: Win32, defect, P3)

63 Branch
Desktop
Windows
defect

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox65 --- wontfix
firefox74 --- fixed

People

(Reporter: mayhemer, Assigned: agashlin)

References

Details

Attachments

(1 file)

      No description provided.
Causing WaitForInputIdle to just loop.  The console has to be manually closed when the launcher is the last process running to end the debugger session "gracefully."

ERROR_NOT_GUI_PROCESS docs don't say much :/
Summary: WaitForInputIdle alwa → With a debugger attached, WaitForInputIdle always returns WAIT_FAILED and GetLastError() == ERROR_NOT_GUI_PROCESS
Priority: -- → P3
Summary: With a debugger attached, WaitForInputIdle always returns WAIT_FAILED and GetLastError() == ERROR_NOT_GUI_PROCESS → With a debugger attached, debug builds laucher process hangs (WaitForInputIdle always returns WAIT_FAILED and GetLastError() == ERROR_NOT_GUI_PROCESS)
Summary: With a debugger attached, debug builds laucher process hangs (WaitForInputIdle always returns WAIT_FAILED and GetLastError() == ERROR_NOT_GUI_PROCESS) → With a debugger attached, debug builds laucher process hangs at shutdown (WaitForInputIdle always returns WAIT_FAILED and GetLastError() == ERROR_NOT_GUI_PROCESS)
See Also: → 1606414

I noticed something similar when diagnosing bug 1606414, this seems to affect ASAN builds in particular when updating. Without the debugger attached there's a 10 second timeout, but by then the updater has already finished waiting for the main process to exit.

I think the issue is that ::WaitForInputIdle() doesn't always set the last-error code when it returns WAIT_FAILED. The documentation never claims it does, which I missed in the review for bug 1477402. In particular, when it's given a handle to an exited process, it leaves the error unchanged.

As for why this would happen with ASAN and debug, maybe because the main process sits there far longer without any idle time, or before it becomes non-GUI. I expect it could happen on a normal build, so it'll be a good thing to fix anyway.

A simple fix is to call ::SetLastError(0) before calling ::WaitForInputIdle(), these try builds seem to bear out that it works: before and after.

Assignee: nobody → agashlin
Status: NEW → ASSIGNED
Type: enhancement → defect
OS: Unspecified → Windows
Regressions: 1477402
Hardware: Unspecified → Desktop
Version: Trunk → 63 Branch
Pushed by agashlin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/70d3568ea54f
Clear last-error code before WaitForInputIdle r=aklotz
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: