New issue
Advanced search Search tips

Issue 836977 link

Starred by 2 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

Windows' GetAppOutputWithExitCode() and GetTerminationStatus() exit code semantics do not agree

Project Member Reported by kmarshall@chromium.org, Apr 25 2018

Issue description

GetAppOutputWithExitCode's API contract states that an application can exit normally (resulting in a 'true' return value), but still return a nonzero exit code. This is not possible on Windows, because in the switch case defined in https://cs.chromium.org/chromium/src/base/process/kill_win.cc?rcl=be3bfc9d9de4bd4f49b8cdb8056e6700e6d15af8&l=64 , all nonzero exit codes are treated as crashes.

It might be worth revisiting the switch case in kill_win.cc, or documenting this variance in GetAppOutputWithExitCode()'s comments.
 
Cc: jam@chromium.org
TL;DR - I think that the Windows implementation of GetAppOutputWithExitCode is wrong, probably due to a misreading of its comment.

The comment for GetAppOutputWithExitCode is unclear and should be clarified, and I *think* that the Windows implementation of GetAppOutputInternal is wrong. I think that GetAppOutputWithExitCode() and related functions are supposed to return true if the process is correctly created and if it an exit code is retrieved. I believe that any suggestion that true implies a "normal" exit is in error.

The most common reason for a failure to create a process is probably failure to find the .exe, but pipe creation failure and other problems can also cause it to fail, and these functions to return false. Here are some posix references:

https://cs.chromium.org/chromium/src/base/process/launch_posix.cc?l=651
https://cs.chromium.org/chromium/src/base/process/process_posix.cc?gsn=WaitForExit&l=338
https://cs.chromium.org/chromium/src/base/process/process_posix.cc?l=181&gsn=WaitForExitWithTimeoutImpl

Windows only returns true on a clean exit - I think this is wrong. It may have been based on a misreading of the ambiguous GetAppOutputWithExitCode comment.
https://cs.chromium.org/chromium/src/base/process/launch_win.cc?q=launch_win.cc&sq=package:chromium&l=122

Also, exit_code is always set, but obviously only returns an exit code if the process was created (if the functions return true). The documentation should be clearer on this point.

That said, I am trying to clarify intent from looking at the implementation, which is always dangerous. However I think the intent is fairly clear. Fixing will be slightly dangerous because we have to change the behavior on Windows.

I haven't checked to see who owns this code. Somebody with more experience in this area would need to sanity check my analysis.

Suspecting crrev.com/1291553003 so adding jam@

Sign in to add a comment