• Michael Stahl's avatar
    unoxml: fix data race in CEventDispatcher::callListeners() · 93f3bd54
    Michael Stahl yazdı
    JunitTest_unoxml_complex crashed with an assertion:
    
        error: attempt to increment a singular iterator.
    
    This is because the CEventDispatcher::dispatchEvent() attempts to copy the
    m_TargetListeners onto the stack, before dropping the mutex to call the,
    listeners, but the copy is unintentionally shallow and the ListenerMap
    that is the value of the outer type is not copied, so this member is
    accessed in callListeners() without MutexGuard.
    
    Fix this by replacing ListenerMap* with ListenerMap as the value,
    which also allows getting rid of explicit delete calls.
    
    15 0x00002b7793e5ace8 in abort () at /lib64/libc.so.6
    16 0x00002b77948c1565 in __gnu_debug::_Error_formatter::_M_error() const () at /lib64/libstdc++.so.6
    17 0x00002b77b802a7d8 in __gnu_debug::_Safe_iterator<std::_Rb_tree_const_iterator<std::pair<_xmlNode* const, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener> > >, std::__debug::multimap<_xmlNode*, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener>, std::less<_xmlNode*>, std::allocator<std::pair<_xmlNode* const, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener> > > > >::operator++() (this=0x2b77b7d99c90) at /usr/include/c++/4.8.2/debug/safe_iterator.h:291
    18 0x00002b77b80275ae in DOM::events::CEventDispatcher::callListeners(std::__debug::map<rtl::OUString, std::__debug::multimap<_xmlNode*, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener>, std::less<_xmlNode*>, std::allocator<std::pair<_xmlNode* const, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener> > > >*, std::less<rtl::OUString>, std::allocator<std::pair<rtl::OUString const, std::__debug::multimap<_xmlNode*, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener>, std::less<_xmlNode*>, std::allocator<std::pair<_xmlNode* const, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEventListener> > > >*> > > const&, _xmlNode*, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEvent> const&) (rTMap=std::__debug::map with 1 elements, pNode=0x21a9c10, aType=..., xEvent=...) at /unoxml/source/events/eventdispatcher.cxx:103
            pMap = 0x2203b10
            iter = {first = , second = {<com::sun::star::uno::BaseReference> = {_pInterface = }, <No data fields>}}
            ibound = {first = , second = {<com::sun::star::uno::BaseReference> = {_pInterface = }, <No data fields>}}
            tIter = {first = {pData = }, second = }
    19 0x00002b77b80284e4 in DOM::events::CEventDispatcher::dispatchEvent(DOM::CDocument&, osl::Mutex&, _xmlNode*, com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> const&, com::sun::star::uno::Reference<com::sun::star::xml::dom::events::XEvent> const&) const (this=0x21fbee0, rDocument=..., rMutex=..., pNode=0x2200890, xNode=..., i_xEvent=...) at /unoxml/source/events/eventdispatcher.cxx:242
            captureListeners = std::__debug::map with 0 elements
            targetListeners = std::__debug::map with 1 elements = {[{pData = 0x2202a30}] = 0x2203b10}
    
    Change-Id: I66fb7a461df0f8066383365850536f7b0394306d
    93f3bd54
eventdispatcher.hxx 2.61 KB