« Return to Thread: Process.ExitCode may return an uninitlialized value

Process.ExitCode may return an uninitlialized value

by slashboot :: Rate this Message:

Reply to Author | View in Thread

Hello,

Recently, I run into an issue where Process.ExitCode was returning numbers out of the 0-255 range which turned out to be random numbers. I was trying to figure out how this can happen and found that in ExitCode_internal (see below, this is the latest revision), no checks were made on the return value of the GetExitCodeProcess (process, &code) call which might lead to returning uninitialized exit code if GetExitCodeProcess returns FALSE. That doesn't look right to me..

For some reason that I still can't explain, GetExitCodeProcess was returning FALSE and I saw this message : "GetExitCodeProcess: Can't find process 0x1" on every process that I created (the process didn't seem to execute correctly). Is anyone aware of such kind of problem ? (I'm using an old 1.1.17-2 version). I cannot reproduce this consistently, but each time it happens, no more processes could be created going forward and I need to restart the app.

--
Mahdi.

//trunk/mono/mono/metadata/process.c
gint32 ves_icall_System_Diagnostics_Process_ExitCode_internal (HANDLE process)
{
        DWORD code;
        MONO_ARCH_SAVE_REGS;
        GetExitCodeProcess (process, &code);
#ifdef DEBUG
        g_message (G_GNUC_PRETTY_FUNCTION ": process exit code is %d", code);
#endif
        return(code);
}

 « Return to Thread: Process.ExitCode may return an uninitlialized value