Skip to content

Commit

Permalink
Guard read of rCont_.bIsList with rCont_.rMutex
Browse files Browse the repository at this point in the history
...as had been the case prior to 12dce07
"loplugin:unusedfields - look for fields that can be const, in comphelper"
(which this commit partly reverts; the const'ness of
OInterfaceIteratorHelper2::bIsList had already been reverted, but for no
apparent reason, in 31b0be0 "improve pahole
script and pack a few classes").

That may or may not have been the cause of the apparently-sporadic
UITest_sw_table failure at <https://ci.libreoffice.org//job/lo_ubsan/2096/>,

> /comphelper/source/container/interfacecontainer2.cxx:54:29: runtime error: member call on address 0x606000ed5d20 which does not point to an object of type 'com::sun::star::uno::XInterface'
> 0x606000ed5d20: note: object has invalid vptr
>  22 04 00 14  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  01 00 00 00 be be be be  b0 11 46 00
>               ^~~~~~~~~~~~~~~~~~~~~~~
>               invalid vptr
>     #0 0x2ab564a71e15 in comphelper::OInterfaceIteratorHelper2::OInterfaceIteratorHelper2(comphelper::OInterfaceContainerHelper2&) /comphelper/source/container/interfacecontainer2.cxx:54:29
>     #1 0x2ab57614588f in void comphelper::OInterfaceContainerHelper2::forEach<com::sun::star::document::XDocumentEventListener, comphelper::OInterfaceContainerHelper2::NotifySingleListener<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent> >(comphelper::OInterfaceContainerHelper2::NotifySingleListener<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent> const&) /include/comphelper/interfacecontainer2.hxx:261:31
>     #2 0x2ab576144a95 in void comphelper::OInterfaceContainerHelper2::notifyEach<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent>(void (com::sun::star::document::XDocumentEventListener::*)(com::sun::star::document::DocumentEvent const&), com::sun::star::document::DocumentEvent const&) /include/comphelper/interfacecontainer2.hxx:279:5
>     #3 0x2ab57613b277 in (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&) /sfx2/source/notify/globalevents.cxx:505:26
>     #4 0x2ab576131faa in (anonymous namespace)::SfxGlobalEvents_Impl::documentEventOccured(com::sun::star::document::DocumentEvent const&) /sfx2/source/notify/globalevents.cxx:256:5
>     #5 0x2ab575f4abfc in (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent>::operator()(com::sun::star::uno::Reference<com::sun::star::document::XDocumentEventListener> const&) const /sfx2/source/doc/sfxbasemodel.cxx:3200:13
>     #6 0x2ab575f002ec in void cppu::OInterfaceContainerHelper::forEach<com::sun::star::document::XDocumentEventListener, (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent> >((anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent> const&) /include/cppuhelper/interfacecontainer.h:292:17
>     #7 0x2ab575efdd37 in SfxBaseModel::postEvent_Impl(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::frame::XController2> const&) /sfx2/source/doc/sfxbasemodel.cxx:3234:14
>     #8 0x2ab575efa257 in SfxBaseModel::Notify(SfxBroadcaster&, SfxHint const&) /sfx2/source/doc/sfxbasemodel.cxx:2883:9
>     #9 0x2ab57a796d83 in SfxBroadcaster::Broadcast(SfxHint const&) /svl/source/notify/SfxBroadcaster.cxx:39:24
>     #10 0x2ab6010f0e1f in SwLayIdle::SwLayIdle(SwRootFrame*, SwViewShellImp*) /sw/source/core/layout/layact.cxx:2375:24
>     #11 0x2ab60385d4e2 in SwViewShell::LayoutIdle() /sw/source/core/view/viewsh.cxx:723:19
>     #12 0x2ab5ff549ffa in sw::DocumentTimerManager::DoIdleJobs(Timer*) /sw/source/core/doc/DocumentTimerManager.cxx:177:42
>     #13 0x2ab5ff54552a in sw::DocumentTimerManager::LinkStubDoIdleJobs(void*, Timer*) /sw/source/core/doc/DocumentTimerManager.cxx:157:1
>     #14 0x2ab599cf5f41 in Link<Timer*, void>::Call(Timer*) const /include/tools/link.hxx:111:45
>     #15 0x2ab599cf5498 in Timer::Invoke() /vcl/source/app/timer.cxx:75:21
>     #16 0x2ab599b388ea in Scheduler::CallbackTaskScheduling() /vcl/source/app/scheduler.cxx:471:20
>     #17 0x2ab59ad34490 in SalTimer::CallCallback() /vcl/inc/saltimer.hxx:54:13
>     #18 0x2ab59ad2785c in SvpSalInstance::CheckTimeout(bool) /vcl/headless/svpinst.cxx:215:53
>     #19 0x2ab59ad2e67c in SvpSalInstance::DoYield(bool, bool) /vcl/headless/svpinst.cxx:460:21
>     #20 0x2ab599c35aa9 in ImplYield(bool, bool) /vcl/source/app/svapp.cxx:465:48
>     #21 0x2ab599c34c67 in Application::Yield() /vcl/source/app/svapp.cxx:532:5
>     #22 0x2ab599c348ae in Application::Execute() /vcl/source/app/svapp.cxx:444:9
>     #23 0x2ab55d699b4b in desktop::Desktop::Main() /desktop/source/app/app.cxx:1603:13
>     #24 0x2ab599cde4e9 in ImplSVMain() /vcl/source/app/svmain.cxx:199:35
>     #25 0x2ab599ce7510 in SVMain() /vcl/source/app/svmain.cxx:231:12
>     #26 0x2ab55d890775 in soffice_main /desktop/source/app/sofficemain.cxx:98:12
>     #27 0x4efc6c in sal_main /desktop/source/app/main.c:49:15
>     #28 0x4efc46 in main /desktop/source/app/main.c:47:1
>     #29 0x2ab55f48e554 in __libc_start_main (/lib64/libc.so.6+0x22554)
>     #30 0x41b5c1 in _start (/instdir/program/soffice.bin+0x41b5c1)

Change-Id: Iaa930f1612a3bb6ad0bcad12f3995b7dbb2e5fa7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120205
Reviewed-by: Noel Grandin <[email protected]>
Reviewed-by: Stephan Bergmann <[email protected]>
Tested-by: Jenkins
  • Loading branch information
stbergmann committed Aug 9, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5ba46ce commit 73b4922
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions comphelper/source/container/interfacecontainer2.cxx
Original file line number Diff line number Diff line change
@@ -37,13 +37,13 @@ namespace comphelper
{

OInterfaceIteratorHelper2::OInterfaceIteratorHelper2( OInterfaceContainerHelper2 & rCont_ )
: rCont( rCont_ ),
bIsList( rCont_.bIsList )
: rCont( rCont_ )
{
MutexGuard aGuard( rCont.rMutex );
if( rCont.bInUse )
// worst case, two iterators at the same time
rCont.copyAndResetInUse();
bIsList = rCont_.bIsList;
aData = rCont_.aData;
if( bIsList )
{

0 comments on commit 73b4922

Please sign in to comment.