VirtualBox

Changeset 55457 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Apr 27, 2015 4:37:15 PM (10 years ago)
Author:
vboxsync
Message:

Main/Host: make sure that all relevant objects are uninitialized when the Host object is uninitialized, otherwise there will be races (especially when API clients crash) between the VirtualBox object shutdown and the other objects which might get cleaned up a little later, resulting in "pure virtual function" calls due to using the vtable of the VirtualBox object after it was freed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r55436 r55457  
    476476     * Note that unregisterMetrics() has unregistered all metrics associated
    477477     * with Host including network interface ones. We can destroy network
    478      * interface objects now.
     478     * interface objects now. Don't forget the uninit call, otherwise this
     479     * causes a race with crashing API clients getting their stale references
     480     * cleaned up and VirtualBox shutting down.
    479481     */
    480     m->llNetIfs.clear();
     482    while (!m->llNetIfs.empty())
     483    {
     484        ComObjPtr<HostNetworkInterface> &pNet = m->llNetIfs.front();
     485        pNet->uninit();
     486        m->llNetIfs.pop_front();
     487    }
    481488
    482489#ifdef VBOX_WITH_USB
     
    493500#ifdef VBOX_WITH_USB
    494501    /* uninit all USB device filters still referenced by clients
    495      * Note! HostUSBDeviceFilter::uninit() will modify llChildren. */
     502     * Note! HostUSBDeviceFilter::uninit() will modify llChildren.
     503     * This list should be already empty, but better be safe than sorry. */
    496504    while (!m->llChildren.empty())
    497505    {
    498506        ComObjPtr<HostUSBDeviceFilter> &pChild = m->llChildren.front();
     507        pChild->uninit();
    499508        m->llChildren.pop_front();
    500         pChild->uninit();
    501     }
    502 
     509    }
     510
     511    /* No need to uninit these, as either Machine::uninit() or the above loop
     512     * already covered them all. Subset of llChildren. */
    503513    m->llUSBDeviceFilters.clear();
    504514#endif
     515
     516    /* uninit all host DVD medium objects */
     517    while (!m->llDVDDrives.empty())
     518    {
     519        ComObjPtr<Medium> &pMedium = m->llDVDDrives.front();
     520        pMedium->uninit();
     521        m->llDVDDrives.pop_front();
     522    }
     523    /* uninit all host floppy medium objects */
     524    while (!m->llFloppyDrives.empty())
     525    {
     526        ComObjPtr<Medium> &pMedium = m->llFloppyDrives.front();
     527        pMedium->uninit();
     528        m->llFloppyDrives.pop_front();
     529    }
    505530
    506531    delete m;
     
    18461871                }
    18471872                if (!fFound)
     1873                {
     1874                    pCached->uninit();
    18481875                    itCached = pllCached->erase(itCached);
     1876                }
    18491877                else
    18501878                    ++itCached;
     
    29903018            {
    29913019                fGone = false;
     3020                (*itNew)->uninit();
    29923021                listCopy.erase(itNew);
    29933022                break;
     
    29983027# ifdef VBOX_WITH_RESOURCE_USAGE_API
    29993028            (*itOld)->i_unregisterMetrics(aCollector, this);
     3029            (*itOld)->uninit();
    30003030# endif
    30013031        }
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