#1273 Process Monitor Thread Error


When running tests dispatched from an Ubuntu Linux installation to our Windows 2003 Server we repeatedly see the following in the trace log on the windows box:
20090706-13:27:43;3436;00000100;Got WAIT_FAILED from WaitForMultipleObjects() in ProcessMonitorThread(), OS_RC: 6
I am guessing the issue lies within stafif\win32\STAFProcess.cpp:245

Instead of:
if (numHandles == (MAXIMUM_WAIT_OBJECTS - 1)) break;
you probably want:
if (numHandles == (MAXIMUM_WAIT_OBJECTS - 2)) break;

So that the last element of handles is monitorWakeUp. Otherwise you are overflowing the array.


  • Sharon Lucas

    Sharon Lucas - 2009-07-06
    • assigned_to: nobody --> slucas
  • Sharon Lucas

    Sharon Lucas - 2009-07-06
    • labels: 357172 --> Service::Process
  • Sharon Lucas

    Sharon Lucas - 2009-07-07

    Making the change you suggested shouldn't make any difference. Note that the numHandles is essentially being incremented "after" it is used as an index for the handles array so the array is not being overflowed.

    for(iter = threadData->monitorMap.begin();
    iter != threadData->monitorMap.end();
    if (numHandles == (MAXIMUM_WAIT_OBJECTS - 1)) break;

    handles[numHandles++] = iter->first;

    handles[numHandles++] = threadData->monitorWakeUp;

    I did some tests and I haven't been able to recreate this issue yet on my Windows machines.

    When WaitForMultipleObjects() fails with WAIT_FAILED, STAF calls GetLastError() to get more information on the error and it is returning Windows system error code 6 (ERROR_INVALID_HANDLE), as seen in the error message as "OS_RC: 6", which indicates an invalid handle. I'm googling to try to find reasons on what can cause this error when calling WaitForMultipleObjects().

    What is the result of running the following on your Windows 2003 Server machine?

    STAF local VAR RESOLVE STRING {STAF/Config/Processor/NumAvail}

  • David Gorton

    David Gorton - 2009-07-08

    When we run the STAF command below we see:

    STAF local VAR resolve string {STAF/Config/Processor/NumAvail}

    Thanks for looking into this.

  • Sharon Lucas

    Sharon Lucas - 2009-07-16

    What version of STAF are you running?

  • David Gorton

    David Gorton - 2009-07-16

    We are currently running 3.3.4. We have also seen the issue on 3.3.3.


Log in to post a comment.