VirtualBox

Changeset 52016 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Jul 14, 2014 12:31:48 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94983
Message:

Main/include/objectslist.h: fix synchronization (lock order violation, hidden from the validator because it uses event semaphores) for list destruction

File:
1 edited

Legend:

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

    r44529 r52016  
    125125    void uninitAll()
    126126    {
     127        /* The implementation differs from the high level description, because
     128         * it isn't safe to hold any locks when invoking uninit() methods. It
     129         * leads to incorrect lock order (first lock, then the Caller related
     130         * event semaphore) and thus deadlocks. Dropping the lock is vital,
     131         * and means we can't rely on iterators while not holding the lock. */
    127132        AutoWriteLock al(m_lock COMMA_LOCKVAL_SRC_POS);
    128         for (iterator it = m_ll.begin();
    129              it != m_ll.end();
    130              ++it)
     133        while (!m_ll.empty())
    131134        {
    132             MyType &q = *it;
     135            /* Need a copy of the element, have to delete the entry before
     136             * dropping the lock, otherwise someone else might mess with the
     137             * list in the mean time, leading to erratic behavior. */
     138            MyType q = m_ll.front();
     139            m_ll.pop_front();
     140            al.release();
    133141            q->uninit();
     142            al.acquire();
    134143        }
    135         m_ll.clear();
    136144    }
    137145
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