VirtualBox

Changeset 56448 in vbox


Ignore:
Timestamp:
Jun 16, 2015 1:09:31 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101065
Message:

Main/Session: Fix possible deadlock in Session:i_unlockMachine(). Releasing the lock had no effect because the write lock was acquired twice

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/SessionImpl.h

    r55800 r56448  
    141141
    142142
    143     HRESULT i_unlockMachine(bool aFinalRelease, bool aFromServer);
     143    HRESULT i_unlockMachine(bool aFinalRelease, bool aFromServer, AutoWriteLock *pLockW);
    144144
    145145    SessionState_T mState;
  • trunk/src/VBox/Main/src-client/SessionImpl.cpp

    r55988 r56448  
    123123               mState == SessionState_Spawning);
    124124
    125         HRESULT rc = i_unlockMachine(true /* aFinalRelease */, false /* aFromServer */);
     125        HRESULT rc = i_unlockMachine(true /* aFinalRelease */, false /* aFromServer */, &alock);
    126126        AssertComRC(rc);
    127127    }
     
    240240
    241241    CHECK_OPEN();
    242 
    243     return i_unlockMachine(false /* aFinalRelease */, false /* aFromServer */);
     242    return i_unlockMachine(false /* aFinalRelease */, false /* aFromServer */, &alock);
    244243}
    245244
     
    535534
    536535        /* close ourselves */
    537         rc = i_unlockMachine(false /* aFinalRelease */, true /* aFromServer */);
     536        rc = i_unlockMachine(false /* aFinalRelease */, true /* aFromServer */, &alock);
    538537    }
    539538    else if (getObjectState().getState() == ObjectState::InUninit)
     
    10581057 *  @param aFinalRelease    called as a result of FinalRelease()
    10591058 *  @param aFromServer      called as a result of Uninitialize()
     1059 *  @param pLockW           The write lock this object is protected with.
     1060 *                          Must be acquired already and will be released
     1061 *                          and later reacquired during the unlocking.
    10601062 *
    10611063 *  @note To be called only from #uninit(), #UnlockMachine() or #Uninitialize().
    1062  *  @note Locks this object for writing.
    10631064 */
    1064 HRESULT Session::i_unlockMachine(bool aFinalRelease, bool aFromServer)
     1065HRESULT Session::i_unlockMachine(bool aFinalRelease, bool aFromServer, AutoWriteLock *pLockW)
    10651066{
    10661067    LogFlowThisFuncEnter();
     
    10681069                      aFinalRelease, aFromServer));
    10691070
    1070     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1071 
    10721071    LogFlowThisFunc(("mState=%s, mType=%d\n", Global::stringifySessionState(mState), mType));
     1072
     1073    Assert(pLockW->isWriteLockOnCurrentThread());
    10731074
    10741075    if (mState != SessionState_Locked)
     
    11371138         *  SessionState_Closing here, so it's safe.
    11381139         */
    1139         alock.release();
     1140        pLockW->release();
    11401141
    11411142        LogFlowThisFunc(("Calling mControl->OnSessionEnd()...\n"));
     
    11431144        LogFlowThisFunc(("mControl->OnSessionEnd()=%08X\n", rc));
    11441145
    1145         alock.acquire();
     1146        pLockW->acquire();
    11461147
    11471148        /*
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette