Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Last active March 31, 2016 12:19
Show Gist options
  • Save rolfbjarne/5dcf36e6c36029cb38684dcba7f8ecb9 to your computer and use it in GitHub Desktop.
Save rolfbjarne/5dcf36e6c36029cb38684dcba7f8ecb9 to your computer and use it in GitHub Desktop.
commit f2a80d70e485781c48321fe8ccf7b50d79f63cdc
Author: Rolf Bjarne Kvinge <[email protected]>
Date: Thu Mar 31 14:09:53 2016 +0200
[process] Initialize exit code before calling GetExitCodeProcess.
GetExitCodeProcess may fail (if getting the exit code of an exited process
we only have the pid for) and not write anything to the *code
parameter.
In that case GetExitCodeProcess would return random memory.
If that random memory happened to be 0x103 (259), then Process.HasExited
would return false, even though the process had actually exited.
Due to the reference import of Process in master, this code is
completely different there, and this bug probably only occurs on
the mono-4.4.0-branch.
diff --git a/mono/metadata/process.c b/mono/metadata/process.c
index f662cf6..5794956 100644
--- a/mono/metadata/process.c
+++ b/mono/metadata/process.c
@@ -867,7 +867,7 @@ gint64 ves_icall_System_Diagnostics_Process_StartTime_internal (HANDLE process)
gint32 ves_icall_System_Diagnostics_Process_ExitCode_internal (HANDLE process)
{
- DWORD code;
+ DWORD code = 0;
GetExitCodeProcess (process, &code);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment