Mike Miller created DAEMON-286:
----------------------------------

             Summary: Race condition during stopping service
                 Key: DAEMON-286
                 URL: https://issues.apache.org/jira/browse/DAEMON-286
             Project: Commons Daemon
          Issue Type: Bug
          Components: Procrun
    Affects Versions: 1.0.13
         Environment: Windows 7 64 bit
            Reporter: Mike Miller
            Priority: Minor


While debugging an issue where ProcRun NT Service hangs in the stopping state, 
I noticed a race condition that causes 2 possible code paths during stopping.   
 
serviceStop() calls afxJavaStart(...).  I have observed apxJavaStart() returns 
both TRUE & FALSE for a successful call to my stop method.  I think this is 
caused by a potential race condition in apxJavaStart() & __apxJavaWorkerThread. 
 The afxJavaStart() waits for lpJava->hWorkerSync event to be set and then 
checks the lpJava->dwWorkerStatus.  The race condition is that 
__apxJavaWorkerThread sets the dwWorkerStatus to 1 and sets the event but there 
is no guarantee that afxJavaStart() will see the 1.  If the 
__apxJavaWorkerThread completes the stop call before afxJavaStart has a chance 
to check the dwWorkerStatus, the __apxJavaWorkerThread may have changed the 
dwWorkerStatus back to 0.   So depending on timing, it appears apxJavaStart() 
could return either TRUE or FALSE even if the stop method behaved the same.
 
This race condition results in the stopService() method not always calling 
afxjavaWait(hWorker, INFINITE,...). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to