Archived

This forum has been archived. Please start a new discussion on GitHub.

Race condition in Outgoing.cpp

Hi

There is a race condition caused assert failure in Outgoing.cpp at line 167. The following is the relevant code fragment:
	    if(timedOut)
	    {
		//
		// Must be called outside the synchronization of this
		// object.
		//
		_connection->exception(TimeoutException(__FILE__, __LINE__));

		//
		// We must wait until the exception set above has
		// propagated to this Outgoing object.
		//
		{
		    IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
		    
		    while(_state == StateInProgress)
		    {
			wait();
		    }

--> assert fails :    assert(_exception.get());
		}
	    }

The code detects a TimeoutException and sets it in the 'Connection' object, and then waits for it to get propagated to the 'Outgoing' object. But there is race condition where the assert on line 167 may fail. This will be caused if just after the the timeout detection in Outgoing, the remote method call completes successfully. In this case the TimeoutException will not be propagated to the Outgoing object, and thus the assert on line 167 will fail.
As a quickfix to the problem in our application, we have disabled the 'assert' on line 167.

Comments

  • marc
    marc Florida
    Thanks a lot for spotting this! We will fix this in the next release.