VirtualBox

Changeset 34499 in vbox


Ignore:
Timestamp:
Nov 30, 2010 12:25:04 PM (14 years ago)
Author:
vboxsync
Message:

Main/Medium: prevent VirtualBox object refcount reaching zero while a task is running

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MediumImpl.cpp

    r33921 r34499  
    194194          mMediumCaller(aMedium),
    195195          mThread(NIL_RTTHREAD),
    196           mProgress(aProgress)
     196          mProgress(aProgress),
     197          mVirtualBoxCaller(NULL)
    197198    {
    198199        AssertReturnVoidStmt(aMedium, mRC = E_FAIL);
    199200        mRC = mMediumCaller.rc();
     201        if (FAILED(mRC))
     202            return;
     203
     204        /* Get strong VirtualBox reference, see below. */
     205        VirtualBox *pVirtualBox = aMedium->m->pVirtualBox;
     206        mVirtualBox = pVirtualBox;
     207        mVirtualBoxCaller.attach(pVirtualBox);
     208        mRC = mVirtualBoxCaller.rc();
    200209        if (FAILED(mRC))
    201210            return;
     
    253262    VDINTERFACE mVDIfProgress;
    254263    VDINTERFACEPROGRESS mVDIfCallsProgress;
     264
     265    /* Must have a strong VirtualBox reference during a task otherwise the
     266     * reference count might drop to 0 while a task is still running. This
     267     * would result in weird behavior, including deadlocks due to uninit and
     268     * locking order issues. The deadlock often is not detectable because the
     269     * uninit uses event semaphores which sabotages deadlock detection. */
     270    ComObjPtr<VirtualBox> mVirtualBox;
     271    AutoCaller mVirtualBoxCaller;
    255272};
    256273
Note: See TracChangeset for help on using the changeset viewer.

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